summaryrefslogtreecommitdiffstats
path: root/sys/net/hfsc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Don't let HFSC force the packet priority to 7 when enableddlg2018-10-221-2/+1
| | | | | | | | | | | | HFSC on a vlan(4) (or similar) interface caused all packets over that interface to get marked with the highest packet priority, no matter what the rest of the system said about it. Leaving the prio alone lets the rest of the network still do something useful, not matter whether the local system queues packets in a particular way. Reported by and fix tested by Adrian Close ok claudio@ kn@ mikeb@
* Remove compatibility with pfctl from 6.1 and plug a few leaksmikeb2018-04-131-23/+20
| | | | No objections from henning, OK visa
* Remove a class from parent's active list when queue is emptymikeb2017-08-171-13/+19
| | | | | | | | | | | | When hfsc_deq_begin can't obtain an mbuf from the queue which can happen with fq_codel, the hfsc_deq_commit isn't called and HFSC doesn't get to update the active queue list of the parent class. To successfully purge and destroy such class, we need to make sure to run the service curve update routine even if we haven't dequeued anything so that the parent class doesn't accumulate stale child classes on its active list. Reported by Atanas Vladimirov, OK visa
* Resolve races with the hfsc_deferred timeoutmikeb2017-08-171-8/+12
| | | | | | | | | | | | | | | | | | Since NET_LOCK no longer protects the ioctl path from timeouts running while ifq configuration is happening, the hfsc_deferred timeout needs to make sure that the underlying HFSC object is locked before attempting to reference it. This prevents the race happening after we release the ifq mutex in ifq_attach but before hfsc_free disables the timeout. The second race is possible after hfsc_alloc but before the ifq mutex gets locked in ifq_attach and a new set of ifq operations is installed. If hfsc_deferred fires in between, it wouldn't be able to reschedule itself and will no longer be executed. To prevent this, the timeout can be established when packets are enqueued instead of the moment the queue is created. With input and OK visa
* Don't attempt to deactivate a class that doesn't have any packets in itmikeb2017-07-241-2/+9
| | | | | | | | | Classes are considered "active" when they have packets assigned to them. Active classes are tracked on various lists and during the purge operation must be dissociated from them. During factoring out of the HFSC internal FIFO operations, the check for whether the class is empty got lost. Issue reported and fix tested by abieber@ and myself.
* Fix the test condition weakened a recent changemikeb2017-07-191-2/+2
|
* Factor out internal FIFO queue managermikeb2017-07-191-37/+165
| | | | | | | HFSC internal queue becomes accessible via pf queueing ops. It will also select an alternative queue manager based on the queue spec. Discussed with and OK henning@ at d2k17 as a part of a larger diff.
* hfsc.c should depend on pf instead of inetmikeb2017-06-281-5/+1
| | | | Discussed with and OK henning@ at d2k17 as a part of a larger diff.
* have the timeout call if qstart via the serialiser isntead of directlydlg2017-06-121-2/+2
| | | | | | | | | | | | | | | | hfsc schedules a timeout to keep traffic moving if somethings has been delayed an no other tx activity has occurred. that timeout was calling (*ifp->if_qstart)(ifq) rather than ifq_start. the latter prevents concurrent calls to if_qstart. without this change bjorn ketelaars on misc@ was experiencing weird pauses in traffic and lockups because the tx ring was corrupted because re_start was run concurrently, once from the stack and once from hfsc. thanks to bjorn ketelaars for debugging, and mikeb@ for most of the legwork in diagnosing the problem. ok mikeb@
* Add a compatibility shim for older pfctl binariesmikeb2017-05-081-1/+9
| | | | Found by and input from dlg@, OK sthen, tedu, henning
* Provide pluggable queueing interface for pfmikeb2017-05-021-4/+25
| | | | | | | | | | | | | By hiding H-FSC behind pfq_ops structure similar to the ifq_ops, we provide a possibility to plug alternative queueing interfaces for use in pf. This reduces amount of H-FSC specific code in the pf ioctl handler While here, change the the order of elements in hfsc_class_stats to provide some compatibility between queue stat structures of different traffic conditioners. No objections from henning@, ok sthen@
* Perform H-FSC root queue allocation in the kernelmikeb2017-04-261-10/+17
| | | | | | | | | Since only leaf queues can have packets assigned to them, H-FSC requires the user specified root queue to have a parent. To simplify userland tools and the configuration interface, the kernel can be leveraged to set it up. ok henning
* deprecate ifq_enqueue_try, and let backends drop arbitrary mbufs.dlg2017-03-071-6/+6
| | | | | | | | | | | | | | | | | | mikeb@ wants priq to be able to drop lower priority packets if the current one is high. because ifq avoids freeing an mbuf while an ifq mutex is held, he needs a way for a backend to return an arbitrary mbuf to drop rather than signal that the current one needs to be dropped. this lets the backends return the mbuf to be dropped, which may or may not be the current one. to support this ifq_enqueue_try has to be dropped because it can only signal about the current mbuf. nothing uses it (except ifq_enqueue), so we can get rid of it. it wasnt even documented. this diff includes some tweaks by mikeb@ around the statistics gathered in ifq_enqueue when an mbuf is dropped.
* add support for multiple transmit ifqueues per network interface.dlg2017-01-241-15/+29
| | | | | | | | | | | | | | | | | | | | | | | an ifq to transmit a packet is picked by the current traffic conditioner (ie, priq or hfsc) by providing an index into an array of ifqs. by default interfaces get a single ifq but can ask for more using if_attach_queues(). the vast majority of our drivers still think there's a 1:1 mapping between interfaces and transmit queues, so their if_start routines take an ifnet pointer instead of a pointer to the ifqueue struct. instead of changing all the drivers in the tree, drivers can opt into using an if_qstart routine and setting the IFXF_MPSAFE flag. the stack provides a compatability wrapper from the new if_qstart handler to the previous if_start handlers if IFXF_MPSAFE isnt set. enabling hfsc on an interface configures it to transmit everything through the first ifq. any other ifqs are left configured as priq, but unused, when hfsc is enabled. getting this in now so everyone can kick the tyres. ok mpi@ visa@ (who provided some tweaks for cnmac).
* white space fixes. no functional change.dlg2017-01-221-7/+7
|
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-7/+5
| | | | | | | | | | | | | | | | | | | | | | the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
* simplify ifq_deq_rollback by only having it unlock.dlg2015-11-211-13/+8
| | | | | | | | | | | hfsc needed a rollback ifqop to requeue the mbuf because it used ml_dequeue in the begin op. now it uses MBUF_LIST_FIRST to get a ref to the first mbuf in deq_begin. now the disciplines dont need a rollback op, so ifq_deq_rollback can be simplified to just releasing the mutex. based on a discussion with kenjiro cho
* shuffle struct ifqueue so in flight mbufs are protected by a mutex.dlg2015-11-201-169/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the code is refactored so the IFQ macros call newly implemented ifq functions. the ifq code is split so each discipline (priq and hfsc in our case) is an opaque set of operations that the common ifq code can call. the common code does the locking, accounting (ifq_len manipulation), and freeing of the mbuf if the disciplines enqueue function rejects it. theyre kind of like bufqs in the block layer with their fifo and nscan disciplines. the new api also supports atomic switching of disciplines at runtime. the hfsc setup in pf_ioctl.c has been tweaked to build a complete hfsc_if structure which it attaches to the send queue in a single operation, rather than attaching to the interface up front and building up a list of queues. the send queue is now mutexed, which raises the expectation that packets can be enqueued or purged on one cpu while another cpu is dequeueing them in a driver for transmission. a lot of drivers use IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before committing to it with a later IFQ_DEQUEUE operation. if the mbuf gets freed in between the POLL and DEQUEUE operations, fireworks will ensue. to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback, and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq mutex and get a reference to the mbuf they wish to try and tx. if there's space, they can ifq_deq_commit it to remove the mbuf and release the mutex. if there's no space, ifq_deq_rollback simply releases the mutex. this api was developed to make updating the drivers using IFQ_POLL easy, instead of having to do significant semantic changes to avoid POLL that we cannot test on all the hardware. the common code has been tested pretty hard, and all the driver modifications are straightforward except for de(4). if that breaks it can be dealt with later. ok mpi@ jmatthew@
* kenjiro cho points out that requeue is hard to support on queuedlg2015-11-091-39/+4
| | | | | | | | | | disciplines while i was simply concerned with the safety of the mbuf, requeue is weird when it comes to how statistics are supposed to be handled and ultimately isnt worth it. this removes hfsc_requeue.
* pass the right sizes to free.dlg2015-10-231-9/+8
|
* inline the hfsc_active TAILQ.dlg2015-10-231-40/+19
| | | | | make cl_actc in hfsc_class a TAILQ rather than a pointer to a TAILQ that gets allocated seaprately.
* inline the hif_eligible TAILQ.dlg2015-10-231-48/+26
| | | | | | | make hif_eligible in hfsc_if a TAILQ rather than a pointer to a TAILQ that gets allocated separately. "look ma, i saved 4 or 8 bytes"
* counting packets in hif_packets in hfsc_if is redundant.dlg2015-10-231-6/+2
| | | | | the ifqueue struct has the same information, and hif_packets is never read separately. trim it.
* remove the pointer from hfsc_class structs back to hfsc_if.dlg2015-10-231-56/+51
| | | | | | | | | you get to hfsc_class via a hfsc_if, so just pass the hfsc_if around on the stack when we need it rather than following the pointer back. most of this change is passing the hif on the stack. ok mpi@ henning@
* rename the internal functions that do ml_foo ops on classes to hfsc_cl_foo.dlg2015-09-301-18/+19
| | | | | | | | this avoids confusion with the public functions (hfsc_enqueue, hfsc_dequeue, etc), and maps almost 1:1 to the mbuf list ops they now use. ok mpi@ henning@ mikeb@
* provide a hfsc_requeue()dlg2015-09-301-2/+26
| | | | | | | | | | this will allow packets to taken off an interfaces send queue, and requeued if space didnt exist on the hardware. the internal names are a bit ugly, i want to change them in the next commit. ok henning@ mpi@
* pull the m_freem calls out of hfsc_enqueue by having IFQ_ENQUEUE freedlg2015-09-271-5/+2
| | | | | | the mbuf in both the hfsc and priq error paths. ok mikeb@ mpi@ claudio@ henning@
* replace the hand rolled lists of mbufs in hfsc_classq with andlg2015-04-181-40/+20
| | | | | | | | | | | | | | mbuf_list. hfsc lists are very clever because they manage a fifo with a single pointer by abusing the m_next pointer of the tail mbuf to point to the head. clever but hard to read. mbuf_lists are slightly bigger because they explicitely track the head mbuf, but i got us that space back by inlining hfsc_classq into hfsc_class and removing the unnecessary classq field. ok henning@
* hfsc_classq has a type member which is never set or read, except to reportdlg2015-04-121-3/+2
| | | | | | | | its value to userland which will always be 0. drop the member. lie to userland. ok henning@
* there's a 1:1 correlation between hfsc_class instances and hfsc_classqdlg2015-04-121-30/+24
| | | | | | | | | instances, so maintaining separate pools for them and pointing between them is overhead. this drops the hfsc_classq pool and inlines it into hfsc_class. ok henning@
* pull structs and macros that are only used in hfsc.c out of the headerdlg2015-04-121-1/+145
| | | | | | and into the .c file. ok henning@
* the hfsc pools are only used in hfsc.c, so move the init of themdlg2015-04-111-1/+14
| | | | | | there instead of pf_ioctl.c. ok henning@
* make sure hfsc_attach, hfsc_detach, hfsc_addqueue, hfsc_delqueue andhenning2015-03-031-3/+16
| | | | | | hfsc_qstats cope with a NULL ifp. Can happen when refering to nonexistant interfaces from pf.conf. Problem noticed and fix tested by Kevin Chadwick <ma1l1ists at yahoo.co.uk>, ok phessler benno
* remove the dead code inside #if(def) RED_NOTYEThenning2015-02-081-59/+3
| | | | | | if we ever do sth like RED again it almost certainly won't be RED; the code isn't even in a state to be useful as documentation/hint, and even if it was it could be retrieved from the attic.
* using IFQ_INC_LEN and IFQ_DEC_LEN for len++/len-- is a bit excessive,henning2015-02-061-4/+4
| | | | | especially given that these are the only users of these macros. ok claudio
* More malloc() -> mallocarray() in the kernel.doug2014-12-091-2/+3
| | | | ok deraadt@ tedu@
* Explicitly include <net/if_var.h> instead of pulling it in <net/if.h>.mpi2014-12-051-1/+2
| | | | ok mikeb@, krw@, bluhm@, tedu@
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-6/+6
| | | | after discussions with beck deraadt kettenis.
* Attach HFSC after it's been completely initialized.pelikan2014-06-301-5/+5
| | | | | | | This fixes the "integer divide fault trap" bug caused by the second malloc skipping a beat and leaving the amount of allocated queues equal to zero. tested by me, ok henning mikeb
* now that if_snd is a proper ifqueue, this cast dieshenning2014-04-191-2/+2
|
* Make the amount of classes limited by 64k, with automatic table growing.pelikan2014-01-271-9/+45
| | | | | | The limit is because in places, queue IDs are being stored as u_int16_t's. tested by me, discussed at length with (and ok) claudio henning
* Purging a queue requires it to be non-empty, not empty.pelikan2014-01-031-2/+2
| | | | ok millert
* Switch frequently allocated structs from malloc(M_DEVBUF) to separate pools.pelikan2014-01-031-20/+17
| | | | ok henning, "looks fine" mikeb, input from guenther.
* Destroy the eligible list when detaching from an interface.pelikan2014-01-011-3/+7
| | | | ok henning
* push the queues every 1/HZ using timeout(9)pelikan2013-11-011-1/+22
| | | | | | | This is a modified version of oldtbr_timeout() with a timeout for each HFSC enabled interface. We can now safely include <sys/timeout.h> in net/hfsc.h without breaking the build. tested by naddy, ok henning claudio deraadt
* revert previous, net/if.h exports bad things to userspace.pelikan2013-10-311-22/+1
|
* push the queues every 1/HZ using timeout(9)pelikan2013-10-311-1/+22
| | | | | | This is a modified version of oldtbr_timeout() with a timeout for each HFSC enabled interface. ok henning claudio
* standalone hfsc implementation with new interface to the consumers, forhenning2013-10-121-0/+1487
the new bandwidth shaping subsystem. looked over & tested by many, ok phessler sthen