xref: /freebsd/sys/net/altq/altq_priq.h (revision 772e66a6fc2fdfca4c9a85dcafbfe4d17c3ddc35)
1*772e66a6SGleb Smirnoff /*-
2*772e66a6SGleb Smirnoff  * Copyright (C) 2000-2003
3*772e66a6SGleb Smirnoff  *	Sony Computer Science Laboratories Inc.  All rights reserved.
4*772e66a6SGleb Smirnoff  *
5*772e66a6SGleb Smirnoff  * Redistribution and use in source and binary forms, with or without
6*772e66a6SGleb Smirnoff  * modification, are permitted provided that the following conditions
7*772e66a6SGleb Smirnoff  * are met:
8*772e66a6SGleb Smirnoff  * 1. Redistributions of source code must retain the above copyright
9*772e66a6SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer.
10*772e66a6SGleb Smirnoff  * 2. Redistributions in binary form must reproduce the above copyright
11*772e66a6SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer in the
12*772e66a6SGleb Smirnoff  *    documentation and/or other materials provided with the distribution.
13*772e66a6SGleb Smirnoff  *
14*772e66a6SGleb Smirnoff  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
15*772e66a6SGleb Smirnoff  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*772e66a6SGleb Smirnoff  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*772e66a6SGleb Smirnoff  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
18*772e66a6SGleb Smirnoff  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*772e66a6SGleb Smirnoff  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*772e66a6SGleb Smirnoff  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*772e66a6SGleb Smirnoff  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*772e66a6SGleb Smirnoff  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*772e66a6SGleb Smirnoff  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*772e66a6SGleb Smirnoff  * SUCH DAMAGE.
25*772e66a6SGleb Smirnoff  *
26*772e66a6SGleb Smirnoff  * $KAME: altq_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $
27*772e66a6SGleb Smirnoff  * $FreeBSD$
28*772e66a6SGleb Smirnoff  */
29*772e66a6SGleb Smirnoff 
30*772e66a6SGleb Smirnoff #ifndef _ALTQ_ALTQ_PRIQ_H_
31*772e66a6SGleb Smirnoff #define	_ALTQ_ALTQ_PRIQ_H_
32*772e66a6SGleb Smirnoff 
33*772e66a6SGleb Smirnoff #include <net/altq/altq.h>
34*772e66a6SGleb Smirnoff #include <net/altq/altq_classq.h>
35*772e66a6SGleb Smirnoff #include <net/altq/altq_red.h>
36*772e66a6SGleb Smirnoff #include <net/altq/altq_rio.h>
37*772e66a6SGleb Smirnoff 
38*772e66a6SGleb Smirnoff #ifdef __cplusplus
39*772e66a6SGleb Smirnoff extern "C" {
40*772e66a6SGleb Smirnoff #endif
41*772e66a6SGleb Smirnoff 
42*772e66a6SGleb Smirnoff #define	PRIQ_MAXPRI	16	/* upper limit of the number of priorities */
43*772e66a6SGleb Smirnoff 
44*772e66a6SGleb Smirnoff #ifdef ALTQ3_COMPAT
45*772e66a6SGleb Smirnoff struct priq_interface {
46*772e66a6SGleb Smirnoff 	char	ifname[IFNAMSIZ];	/* interface name (e.g., fxp0) */
47*772e66a6SGleb Smirnoff 	u_long	arg;			/* request-specific argument */
48*772e66a6SGleb Smirnoff };
49*772e66a6SGleb Smirnoff 
50*772e66a6SGleb Smirnoff struct priq_add_class {
51*772e66a6SGleb Smirnoff 	struct priq_interface	iface;
52*772e66a6SGleb Smirnoff 	int			pri;	/* priority (0 is the lowest) */
53*772e66a6SGleb Smirnoff 	int			qlimit;	/* queue size limit */
54*772e66a6SGleb Smirnoff 	int			flags;	/* misc flags (see below) */
55*772e66a6SGleb Smirnoff 
56*772e66a6SGleb Smirnoff 	u_int32_t		class_handle;  /* return value */
57*772e66a6SGleb Smirnoff };
58*772e66a6SGleb Smirnoff #endif /* ALTQ3_COMPAT */
59*772e66a6SGleb Smirnoff 
60*772e66a6SGleb Smirnoff /* priq class flags */
61*772e66a6SGleb Smirnoff #define	PRCF_RED		0x0001	/* use RED */
62*772e66a6SGleb Smirnoff #define	PRCF_ECN		0x0002  /* use RED/ECN */
63*772e66a6SGleb Smirnoff #define	PRCF_RIO		0x0004  /* use RIO */
64*772e66a6SGleb Smirnoff #define	PRCF_CLEARDSCP		0x0010  /* clear diffserv codepoint */
65*772e66a6SGleb Smirnoff #define	PRCF_DEFAULTCLASS	0x1000	/* default class */
66*772e66a6SGleb Smirnoff 
67*772e66a6SGleb Smirnoff /* special class handles */
68*772e66a6SGleb Smirnoff #define	PRIQ_NULLCLASS_HANDLE	0
69*772e66a6SGleb Smirnoff 
70*772e66a6SGleb Smirnoff #ifdef ALTQ3_COMPAT
71*772e66a6SGleb Smirnoff struct priq_delete_class {
72*772e66a6SGleb Smirnoff 	struct priq_interface	iface;
73*772e66a6SGleb Smirnoff 	u_int32_t		class_handle;
74*772e66a6SGleb Smirnoff };
75*772e66a6SGleb Smirnoff 
76*772e66a6SGleb Smirnoff struct priq_modify_class {
77*772e66a6SGleb Smirnoff 	struct priq_interface	iface;
78*772e66a6SGleb Smirnoff 	u_int32_t		class_handle;
79*772e66a6SGleb Smirnoff 	int			pri;
80*772e66a6SGleb Smirnoff 	int			qlimit;
81*772e66a6SGleb Smirnoff 	int			flags;
82*772e66a6SGleb Smirnoff };
83*772e66a6SGleb Smirnoff 
84*772e66a6SGleb Smirnoff struct priq_add_filter {
85*772e66a6SGleb Smirnoff 	struct priq_interface	iface;
86*772e66a6SGleb Smirnoff 	u_int32_t		class_handle;
87*772e66a6SGleb Smirnoff 	struct flow_filter	filter;
88*772e66a6SGleb Smirnoff 
89*772e66a6SGleb Smirnoff 	u_long			filter_handle;  /* return value */
90*772e66a6SGleb Smirnoff };
91*772e66a6SGleb Smirnoff 
92*772e66a6SGleb Smirnoff struct priq_delete_filter {
93*772e66a6SGleb Smirnoff 	struct priq_interface	iface;
94*772e66a6SGleb Smirnoff 	u_long			filter_handle;
95*772e66a6SGleb Smirnoff };
96*772e66a6SGleb Smirnoff #endif /* ALTQ3_COMPAT */
97*772e66a6SGleb Smirnoff 
98*772e66a6SGleb Smirnoff struct priq_classstats {
99*772e66a6SGleb Smirnoff 	u_int32_t		class_handle;
100*772e66a6SGleb Smirnoff 
101*772e66a6SGleb Smirnoff 	u_int			qlength;
102*772e66a6SGleb Smirnoff 	u_int			qlimit;
103*772e66a6SGleb Smirnoff 	u_int			period;
104*772e66a6SGleb Smirnoff 	struct pktcntr		xmitcnt;  /* transmitted packet counter */
105*772e66a6SGleb Smirnoff 	struct pktcntr		dropcnt;  /* dropped packet counter */
106*772e66a6SGleb Smirnoff 
107*772e66a6SGleb Smirnoff 	/* red and rio related info */
108*772e66a6SGleb Smirnoff 	int			qtype;
109*772e66a6SGleb Smirnoff 	struct redstats		red[3];	/* rio has 3 red stats */
110*772e66a6SGleb Smirnoff };
111*772e66a6SGleb Smirnoff 
112*772e66a6SGleb Smirnoff #ifdef ALTQ3_COMPAT
113*772e66a6SGleb Smirnoff struct priq_class_stats {
114*772e66a6SGleb Smirnoff 	struct priq_interface	iface;
115*772e66a6SGleb Smirnoff 	int			maxpri;	  /* in/out */
116*772e66a6SGleb Smirnoff 
117*772e66a6SGleb Smirnoff 	struct priq_classstats	*stats;   /* pointer to stats array */
118*772e66a6SGleb Smirnoff };
119*772e66a6SGleb Smirnoff 
120*772e66a6SGleb Smirnoff #define	PRIQ_IF_ATTACH		_IOW('Q', 1, struct priq_interface)
121*772e66a6SGleb Smirnoff #define	PRIQ_IF_DETACH		_IOW('Q', 2, struct priq_interface)
122*772e66a6SGleb Smirnoff #define	PRIQ_ENABLE		_IOW('Q', 3, struct priq_interface)
123*772e66a6SGleb Smirnoff #define	PRIQ_DISABLE		_IOW('Q', 4, struct priq_interface)
124*772e66a6SGleb Smirnoff #define	PRIQ_CLEAR		_IOW('Q', 5, struct priq_interface)
125*772e66a6SGleb Smirnoff #define	PRIQ_ADD_CLASS		_IOWR('Q', 7, struct priq_add_class)
126*772e66a6SGleb Smirnoff #define	PRIQ_DEL_CLASS		_IOW('Q', 8, struct priq_delete_class)
127*772e66a6SGleb Smirnoff #define	PRIQ_MOD_CLASS		_IOW('Q', 9, struct priq_modify_class)
128*772e66a6SGleb Smirnoff #define	PRIQ_ADD_FILTER		_IOWR('Q', 10, struct priq_add_filter)
129*772e66a6SGleb Smirnoff #define	PRIQ_DEL_FILTER		_IOW('Q', 11, struct priq_delete_filter)
130*772e66a6SGleb Smirnoff #define	PRIQ_GETSTATS		_IOWR('Q', 12, struct priq_class_stats)
131*772e66a6SGleb Smirnoff 
132*772e66a6SGleb Smirnoff #endif /* ALTQ3_COMPAT */
133*772e66a6SGleb Smirnoff 
134*772e66a6SGleb Smirnoff #ifdef _KERNEL
135*772e66a6SGleb Smirnoff 
136*772e66a6SGleb Smirnoff struct priq_class {
137*772e66a6SGleb Smirnoff 	u_int32_t	cl_handle;	/* class handle */
138*772e66a6SGleb Smirnoff 	class_queue_t	*cl_q;		/* class queue structure */
139*772e66a6SGleb Smirnoff 	struct red	*cl_red;	/* RED state */
140*772e66a6SGleb Smirnoff 	int		cl_pri;		/* priority */
141*772e66a6SGleb Smirnoff 	int		cl_flags;	/* class flags */
142*772e66a6SGleb Smirnoff 	struct priq_if	*cl_pif;	/* back pointer to pif */
143*772e66a6SGleb Smirnoff 	struct altq_pktattr *cl_pktattr; /* saved header used by ECN */
144*772e66a6SGleb Smirnoff 
145*772e66a6SGleb Smirnoff 	/* statistics */
146*772e66a6SGleb Smirnoff 	u_int		cl_period;	/* backlog period */
147*772e66a6SGleb Smirnoff 	struct pktcntr  cl_xmitcnt;	/* transmitted packet counter */
148*772e66a6SGleb Smirnoff 	struct pktcntr  cl_dropcnt;	/* dropped packet counter */
149*772e66a6SGleb Smirnoff };
150*772e66a6SGleb Smirnoff 
151*772e66a6SGleb Smirnoff /*
152*772e66a6SGleb Smirnoff  * priq interface state
153*772e66a6SGleb Smirnoff  */
154*772e66a6SGleb Smirnoff struct priq_if {
155*772e66a6SGleb Smirnoff 	struct priq_if		*pif_next;	/* interface state list */
156*772e66a6SGleb Smirnoff 	struct ifaltq		*pif_ifq;	/* backpointer to ifaltq */
157*772e66a6SGleb Smirnoff 	u_int			pif_bandwidth;	/* link bandwidth in bps */
158*772e66a6SGleb Smirnoff 	int			pif_maxpri;	/* max priority in use */
159*772e66a6SGleb Smirnoff 	struct priq_class	*pif_default;	/* default class */
160*772e66a6SGleb Smirnoff 	struct priq_class	*pif_classes[PRIQ_MAXPRI]; /* classes */
161*772e66a6SGleb Smirnoff #ifdef ALTQ3_CLFIER_COMPAT
162*772e66a6SGleb Smirnoff 	struct acc_classifier	pif_classifier;	/* classifier */
163*772e66a6SGleb Smirnoff #endif
164*772e66a6SGleb Smirnoff };
165*772e66a6SGleb Smirnoff 
166*772e66a6SGleb Smirnoff #endif /* _KERNEL */
167*772e66a6SGleb Smirnoff 
168*772e66a6SGleb Smirnoff #ifdef __cplusplus
169*772e66a6SGleb Smirnoff }
170*772e66a6SGleb Smirnoff #endif
171*772e66a6SGleb Smirnoff 
172*772e66a6SGleb Smirnoff #endif /* _ALTQ_ALTQ_PRIQ_H_ */
173