xref: /freebsd/sys/netpfil/pf/pf_altq.h (revision 119b75925c562202145d7bac7b676b98029c6cb9)
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 priq_opts {
49 	int		flags;
50 };
51 
52 struct hfsc_opts {
53 	/* real-time service curve */
54 	u_int		rtsc_m1;	/* slope of the 1st segment in bps */
55 	u_int		rtsc_d;		/* the x-projection of m1 in msec */
56 	u_int		rtsc_m2;	/* slope of the 2nd segment in bps */
57 	/* link-sharing service curve */
58 	u_int		lssc_m1;
59 	u_int		lssc_d;
60 	u_int		lssc_m2;
61 	/* upper-limit service curve */
62 	u_int		ulsc_m1;
63 	u_int		ulsc_d;
64 	u_int		ulsc_m2;
65 	int		flags;
66 };
67 
68 /*
69  * XXX this needs some work
70  */
71 struct fairq_opts {
72 	u_int           nbuckets;
73 	u_int           hogs_m1;
74 	int             flags;
75 
76 	/* link sharing service curve */
77 	u_int           lssc_m1;
78 	u_int           lssc_d;
79 	u_int           lssc_m2;
80 };
81 
82 struct pf_altq {
83 	char			 ifname[IFNAMSIZ];
84 
85 	void			*altq_disc;	/* discipline-specific state */
86 	TAILQ_ENTRY(pf_altq)	 entries;
87 
88 	/* scheduler spec */
89 	uint8_t			 scheduler;	/* scheduler type */
90 	uint16_t		 tbrsize;	/* tokenbucket regulator size */
91 	uint32_t		 ifbandwidth;	/* interface bandwidth */
92 
93 	/* queue spec */
94 	char			 qname[PF_QNAME_SIZE];	/* queue name */
95 	char			 parent[PF_QNAME_SIZE];	/* parent name */
96 	uint32_t		 parent_qid;	/* parent queue id */
97 	uint32_t		 bandwidth;	/* queue bandwidth */
98 	uint8_t			 priority;	/* priority */
99 	uint8_t			 local_flags;	/* dynamic interface */
100 #define	PFALTQ_FLAG_IF_REMOVED		0x01
101 
102 	uint16_t		 qlimit;	/* queue size limit */
103 	uint16_t		 flags;		/* misc flags */
104 	union {
105 		struct cbq_opts		 cbq_opts;
106 		struct priq_opts	 priq_opts;
107 		struct hfsc_opts	 hfsc_opts;
108 		struct fairq_opts        fairq_opts;
109 	} pq_u;
110 
111 	uint32_t		 qid;		/* return value */
112 };
113 
114 #endif	/* _NET_PF_ALTQ_H_ */
115