From: Andrew Lemin Subject: Re: PF Queue bandwidth now 64bit for >4Gbps queues To: Andrew Lemin , tech@openbsd.org, Theo Buehler Date: Thu, 19 Mar 2026 23:54:24 +1100 Ha, Thanks Stuart.. I just sat down and was going to swap those lines, you beat me to it.. Thank you! Thanks again, Andy. On Thu, 19 Mar 2026 at 23:46, Stuart Henderson wrote: > On 2026/03/18 11:28, Stuart Henderson wrote: > > On 2026/03/18 11:01, Stuart Henderson wrote: > > > On 2026/03/18 00:57, Andrew Lemin wrote: > > > > struct hfsc_sc grows from 12 to 24 bytes (with a 4-byte padding hole > > > > between d and m2 due to alignment - should we reorder?). > > > > > > yes. > > > > > > from style(9): > > > > > > When declaring variables in structures, declare them sorted by use, > then > > > by size (largest to smallest), then by alphabetical order. The > first > > > category normally doesn't apply, but there are exceptions. > > > > > > (+ i'll see if I can figure out what's needed in ports-land for this). > > > > > > > +Values up to 999G are supported, allowing configuration of PF queues on > > +10G, 25G, 40G, and 100G interfaces. > > > > I don't think the clause about interface speeds is needed > > Actually I think the manual change should just be dropped, it's not > needed. Diff below drops that and reorders the struct. This version is > ok sthen and I would like this to coincide with library bumps that are > about to take place, so that most packages will get updated anyway > (i.e. commit this first or at the same time as the bumps). > > +Values up to 999G are supported. > > There is a pre-existing issue with pfctl silently mishandling bandwidth > specs above this. That should be fixed rather than rely on someone > reading docs. I think not a blocker for committing the uint64 change. > I'll send a separate mail about this. > > > > Index: regress/sbin/pfctl/Makefile > =================================================================== > RCS file: /cvs/src/regress/sbin/pfctl/Makefile,v > diff -u -p -r1.236 Makefile > --- regress/sbin/pfctl/Makefile 23 Mar 2022 22:07:10 -0000 1.236 > +++ regress/sbin/pfctl/Makefile 19 Mar 2026 11:31:04 -0000 > @@ -18,7 +18,7 @@ PFTESTS=1 2 3 4 5 6 7 8 9 10 11 12 13 14 > PFTESTS+=28 29 30 31 32 34 35 36 38 39 40 41 44 46 47 48 49 50 > PFTESTS+=52 53 54 55 56 57 60 61 65 66 67 68 69 70 71 72 73 > PFTESTS+=74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 > 95 96 > -PFTESTS+=97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 114 > +PFTESTS+=97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 114 115 > PFFAIL=1 2 3 4 5 6 7 8 11 12 13 14 15 16 17 19 20 23 25 27 > PFFAIL+=30 37 38 39 40 41 42 43 47 48 49 50 51 52 53 54 55 56 57 58 59 60 > 61 62 > PFFAIL+=63 64 65 66 67 > Index: regress/sbin/pfctl/pf115.in > =================================================================== > RCS file: regress/sbin/pfctl/pf115.in > diff -N regress/sbin/pfctl/pf115.in > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/sbin/pfctl/pf115.in 19 Mar 2026 11:31:04 -0000 > @@ -0,0 +1,2 @@ > +queue rootq on lo1000000 bandwidth 10G > +queue defq parent rootq bandwidth 8G default > Index: regress/sbin/pfctl/pf115.ok > =================================================================== > RCS file: regress/sbin/pfctl/pf115.ok > diff -N regress/sbin/pfctl/pf115.ok > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/sbin/pfctl/pf115.ok 19 Mar 2026 11:31:04 -0000 > @@ -0,0 +1,2 @@ > +queue rootq on lo1000000 bandwidth 10G > +queue defq parent rootq bandwidth 8G default > Index: sys/net/hfsc.c > =================================================================== > RCS file: /cvs/src/sys/net/hfsc.c,v > diff -u -p -r1.52 hfsc.c > --- sys/net/hfsc.c 22 Nov 2025 05:07:24 -0000 1.52 > +++ sys/net/hfsc.c 19 Mar 2026 11:31:04 -0000 > @@ -229,10 +229,10 @@ struct hfsc_class *hfsc_actlist_firstfit > > static __inline u_int64_t seg_x2y(u_int64_t, u_int64_t); > static __inline u_int64_t seg_y2x(u_int64_t, u_int64_t); > -static __inline u_int64_t m2sm(u_int); > -static __inline u_int64_t m2ism(u_int); > +static __inline u_int64_t m2sm(u_int64_t); > +static __inline u_int64_t m2ism(u_int64_t); > static __inline u_int64_t d2dx(u_int); > -static __inline u_int sm2m(u_int64_t); > +static __inline u_int64_t sm2m(u_int64_t); > static __inline u_int dx2d(u_int64_t); > > void hfsc_sc2isc(struct hfsc_sc *, struct hfsc_internal_sc *); > @@ -1451,16 +1451,16 @@ seg_y2x(u_int64_t y, u_int64_t ism) > } > > static __inline u_int64_t > -m2sm(u_int m) > +m2sm(u_int64_t m) > { > u_int64_t sm; > > - sm = ((u_int64_t)m << SM_SHIFT) / 8 / HFSC_FREQ; > + sm = (m << SM_SHIFT) / 8 / HFSC_FREQ; > return (sm); > } > > static __inline u_int64_t > -m2ism(u_int m) > +m2ism(u_int64_t m) > { > u_int64_t ism; > > @@ -1480,13 +1480,13 @@ d2dx(u_int d) > return (dx); > } > > -static __inline u_int > +static __inline u_int64_t > sm2m(u_int64_t sm) > { > u_int64_t m; > > m = (sm * 8 * HFSC_FREQ) >> SM_SHIFT; > - return ((u_int)m); > + return (m); > } > > static __inline u_int > Index: sys/net/hfsc.h > =================================================================== > RCS file: /cvs/src/sys/net/hfsc.h,v > diff -u -p -r1.14 hfsc.h > --- sys/net/hfsc.h 7 Jul 2025 00:55:15 -0000 1.14 > +++ sys/net/hfsc.h 19 Mar 2026 11:31:04 -0000 > @@ -45,9 +45,9 @@ struct hfsc_pktcntr { > do { (cntr)->packets++; (cntr)->bytes += len; } while (0) > > struct hfsc_sc { > - u_int m1; /* slope of the first segment in bits/sec */ > - u_int d; /* the x-projection of the first segment in msec */ > - u_int m2; /* slope of the second segment in bits/sec */ > + u_int64_t m1; /* slope of the first segment in bits/sec > */ > + u_int64_t m2; /* slope of the second segment in bits/sec > */ > + u_int d; /* the x-projection of the first segment > in msec */ > }; > > /* special class handles */ > Index: usr.bin/systat/pftop.c > =================================================================== > RCS file: /cvs/src/usr.bin/systat/pftop.c,v > diff -u -p -r1.47 pftop.c > --- usr.bin/systat/pftop.c 22 Apr 2024 14:19:48 -0000 1.47 > +++ usr.bin/systat/pftop.c 19 Mar 2026 11:31:04 -0000 > @@ -1611,7 +1611,7 @@ calc_pps(u_int64_t new_pkts, u_int64_t l > void > print_queue_node(struct pfctl_queue_node *node) > { > - u_int rate, rtmp; > + u_int64_t rate, rtmp; > int i; > double interval, pps, bps; > static const char unit[] = " KMG"; > @@ -1641,7 +1641,7 @@ print_queue_node(struct pfctl_queue_node > */ > tbprintf("%u", node->qstats.data.period); > } else > - tbprintf("%u%c", rate, unit[i]); > + tbprintf("%llu%c", (unsigned long long)rate, unit[i]); > print_fld_tb(FLD_BANDW); > > print_fld_str(FLD_SCHED, node->qs.flags & PFQS_FLOWQUEUE ? >