xref: /freebsd/sys/netpfil/pf/pf_altq.h (revision d93a896ef95946b0bf1219866fcb324b78543444)
1 /*
2  * Copyright (c) 2001 Daniel Hartmeier
3  * 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  *
9  *    - Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *    - Redistributions in binary form must reproduce the above
12  *      copyright notice, this list of conditions and the following
13  *      disclaimer in the documentation and/or other materials provided
14  *      with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  *	$OpenBSD: pfvar.h,v 1.282 2009/01/29 15:12:28 pyr Exp $
30  *	$FreeBSD$
31  */
32 
33 #ifndef	_NET_PF_ALTQ_H_
34 #define	_NET_PF_ALTQ_H_
35 
36 struct cbq_opts {
37 	u_int		minburst;
38 	u_int		maxburst;
39 	u_int		pktsize;
40 	u_int		maxpktsize;
41 	u_int		ns_per_byte;
42 	u_int		maxidle;
43 	int		minidle;
44 	u_int		offtime;
45 	int		flags;
46 };
47 
48 struct codel_opts {
49 	u_int		target;
50 	u_int		interval;
51 	int		ecn;
52 };
53 
54 struct priq_opts {
55 	int		flags;
56 };
57 
58 struct hfsc_opts {
59 	/* real-time service curve */
60 	u_int		rtsc_m1;	/* slope of the 1st segment in bps */
61 	u_int		rtsc_d;		/* the x-projection of m1 in msec */
62 	u_int		rtsc_m2;	/* slope of the 2nd segment in bps */
63 	/* link-sharing service curve */
64 	u_int		lssc_m1;
65 	u_int		lssc_d;
66 	u_int		lssc_m2;
67 	/* upper-limit service curve */
68 	u_int		ulsc_m1;
69 	u_int		ulsc_d;
70 	u_int		ulsc_m2;
71 	int		flags;
72 };
73 
74 /*
75  * XXX this needs some work
76  */
77 struct fairq_opts {
78 	u_int           nbuckets;
79 	u_int           hogs_m1;
80 	int             flags;
81 
82 	/* link sharing service curve */
83 	u_int           lssc_m1;
84 	u_int           lssc_d;
85 	u_int           lssc_m2;
86 };
87 
88 struct pf_altq {
89 	char			 ifname[IFNAMSIZ];
90 
91 	void			*altq_disc;	/* discipline-specific state */
92 	TAILQ_ENTRY(pf_altq)	 entries;
93 
94 	/* scheduler spec */
95 	uint8_t			 scheduler;	/* scheduler type */
96 	uint16_t		 tbrsize;	/* tokenbucket regulator size */
97 	uint32_t		 ifbandwidth;	/* interface bandwidth */
98 
99 	/* queue spec */
100 	char			 qname[PF_QNAME_SIZE];	/* queue name */
101 	char			 parent[PF_QNAME_SIZE];	/* parent name */
102 	uint32_t		 parent_qid;	/* parent queue id */
103 	uint32_t		 bandwidth;	/* queue bandwidth */
104 	uint8_t			 priority;	/* priority */
105 	uint8_t			 local_flags;	/* dynamic interface */
106 #define	PFALTQ_FLAG_IF_REMOVED		0x01
107 
108 	uint16_t		 qlimit;	/* queue size limit */
109 	uint16_t		 flags;		/* misc flags */
110 	union {
111 		struct cbq_opts		 cbq_opts;
112 		struct codel_opts	 codel_opts;
113 		struct priq_opts	 priq_opts;
114 		struct hfsc_opts	 hfsc_opts;
115 		struct fairq_opts        fairq_opts;
116 	} pq_u;
117 
118 	uint32_t		 qid;		/* return value */
119 };
120 
121 #endif	/* _NET_PF_ALTQ_H_ */
122