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