/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2001 Daniel Hartmeier4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9*10* - Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* - Redistributions in binary form must reproduce the above13* copyright notice, this list of conditions and the following14* disclaimer in the documentation and/or other materials provided15* with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS18* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS20* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE21* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,23* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER25* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN27* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28* POSSIBILITY OF SUCH DAMAGE.29*30* $OpenBSD: pfvar.h,v 1.282 2009/01/29 15:12:28 pyr Exp $31*/3233#ifndef _NET_PF_ALTQ_H_34#define _NET_PF_ALTQ_H_3536struct cbq_opts {37u_int minburst;38u_int maxburst;39u_int pktsize;40u_int maxpktsize;41u_int ns_per_byte;42u_int maxidle;43int minidle;44u_int offtime;45int flags;46};4748struct codel_opts {49u_int target;50u_int interval;51int ecn;52};5354struct priq_opts {55int flags;56};5758struct hfsc_opts_v0 {59/* real-time service curve */60u_int rtsc_m1; /* slope of the 1st segment in bps */61u_int rtsc_d; /* the x-projection of m1 in msec */62u_int rtsc_m2; /* slope of the 2nd segment in bps */63/* link-sharing service curve */64u_int lssc_m1;65u_int lssc_d;66u_int lssc_m2;67/* upper-limit service curve */68u_int ulsc_m1;69u_int ulsc_d;70u_int ulsc_m2;71int flags;72};7374struct hfsc_opts_v1 {75/* real-time service curve */76u_int64_t rtsc_m1; /* slope of the 1st segment in bps */77u_int rtsc_d; /* the x-projection of m1 in msec */78u_int64_t rtsc_m2; /* slope of the 2nd segment in bps */79/* link-sharing service curve */80u_int64_t lssc_m1;81u_int lssc_d;82u_int64_t lssc_m2;83/* upper-limit service curve */84u_int64_t ulsc_m1;85u_int ulsc_d;86u_int64_t ulsc_m2;87int flags;88};8990/*91* struct hfsc_opts doesn't have a version indicator macro or92* backwards-compat and convenience macros because both in the kernel and93* the pfctl parser, there are struct hfsc_opts instances named 'hfsc_opts'.94* It is believed that only in-tree code uses struct hfsc_opts, so95* backwards-compat macros are not necessary. The few in-tree uses can just96* be updated to the latest versioned struct tag.97*/9899/*100* XXX this needs some work101*/102struct fairq_opts {103u_int nbuckets;104u_int hogs_m1;105int flags;106107/* link sharing service curve */108u_int lssc_m1;109u_int lssc_d;110u_int lssc_m2;111};112113/*114* struct pf_altq_v0, struct pf_altq_v1, etc. are the ioctl argument115* structures corresponding to struct pfioc_altq_v0, struct pfioc_altq_v1,116* etc.117*118*/119struct pf_altq_v0 {120char ifname[IFNAMSIZ];121122/*123* This member is a holdover from when the kernel state structure124* was reused as the ioctl argument structure, and remains to125* preserve the size and layout of this struct for backwards compat.126*/127void *unused1;128TAILQ_ENTRY(pf_altq_v0) entries;129130/* scheduler spec */131uint8_t scheduler; /* scheduler type */132uint16_t tbrsize; /* tokenbucket regulator size */133uint32_t ifbandwidth; /* interface bandwidth */134135/* queue spec */136char qname[PF_QNAME_SIZE]; /* queue name */137char parent[PF_QNAME_SIZE]; /* parent name */138uint32_t parent_qid; /* parent queue id */139uint32_t bandwidth; /* queue bandwidth */140uint8_t priority; /* priority */141uint8_t local_flags; /* dynamic interface */142#define PFALTQ_FLAG_IF_REMOVED 0x01143144uint16_t qlimit; /* queue size limit */145uint16_t flags; /* misc flags */146union {147struct cbq_opts cbq_opts;148struct codel_opts codel_opts;149struct priq_opts priq_opts;150struct hfsc_opts_v0 hfsc_opts;151struct fairq_opts fairq_opts;152} pq_u;153154uint32_t qid; /* return value */155};156157struct pf_altq_v1 {158char ifname[IFNAMSIZ];159160TAILQ_ENTRY(pf_altq_v1) entries;161162/* scheduler spec */163uint8_t scheduler; /* scheduler type */164uint32_t tbrsize; /* tokenbucket regulator size */165uint64_t ifbandwidth; /* interface bandwidth */166167/* queue spec */168char qname[PF_QNAME_SIZE]; /* queue name */169char parent[PF_QNAME_SIZE]; /* parent name */170uint32_t parent_qid; /* parent queue id */171uint64_t bandwidth; /* queue bandwidth */172uint8_t priority; /* priority */173uint8_t local_flags; /* dynamic interface, see _v0 */174175uint16_t qlimit; /* queue size limit */176uint16_t flags; /* misc flags */177union {178struct cbq_opts cbq_opts;179struct codel_opts codel_opts;180struct priq_opts priq_opts;181struct hfsc_opts_v1 hfsc_opts;182struct fairq_opts fairq_opts;183} pq_u;184185uint32_t qid; /* return value */186};187188/* Latest version of struct pf_altq_vX */189#define PF_ALTQ_VERSION 1190191#ifdef _KERNEL192struct pf_kaltq {193char ifname[IFNAMSIZ];194195void *altq_disc; /* discipline-specific state */196TAILQ_ENTRY(pf_kaltq) entries;197198/* scheduler spec */199uint8_t scheduler; /* scheduler type */200uint32_t tbrsize; /* tokenbucket regulator size */201uint64_t ifbandwidth; /* interface bandwidth */202203/* queue spec */204char qname[PF_QNAME_SIZE]; /* queue name */205char parent[PF_QNAME_SIZE]; /* parent name */206uint32_t parent_qid; /* parent queue id */207uint64_t bandwidth; /* queue bandwidth */208uint8_t priority; /* priority */209uint8_t local_flags; /* dynamic interface, see _v0 */210211uint16_t qlimit; /* queue size limit */212uint16_t flags; /* misc flags */213union {214struct cbq_opts cbq_opts;215struct codel_opts codel_opts;216struct priq_opts priq_opts;217struct hfsc_opts_v1 hfsc_opts;218struct fairq_opts fairq_opts;219} pq_u;220221uint16_t qid; /* return value */222};223#endif /* _KERNEL */224225/*226* Compatibility and convenience macros227*/228#ifdef _KERNEL229/*230* Avoid a patch with 100+ lines of name substitution.231*/232#define pf_altq pf_kaltq233234#else /* _KERNEL */235236#ifdef PFIOC_USE_LATEST237/*238* Maintaining in-tree consumers of the ioctl interface is easier when that239* code can be written in terms old names that refer to the latest interface240* version as that reduces the required changes in the consumers to those241* that are functionally necessary to accommodate a new interface version.242*/243#define pf_altq __CONCAT(pf_altq_v, PF_ALTQ_VERSION)244245#else /* PFIOC_USE_LATEST */246/*247* When building out-of-tree code that is written for the old interface,248* such as may exist in ports for example, resolve the old pf_altq struct249* tag to the v0 version.250*/251#define pf_altq __CONCAT(pf_altq_v, 0)252253#endif /* PFIOC_USE_LATEST */254#endif /* _KERNEL */255256#endif /* _NET_PF_ALTQ_H_ */257258259