Subject: Re: [RFC PATCH 00/10] Add a new Qdisc, ETS

From: Petr Machata <[email-masked]>
Date: Thu, 21 Nov 2019 12:43:47 +0000

Jakub Kicinski <[email-masked]> writes:

> On Wed, 20 Nov 2019 13:05:08 +0000, Petr Machata wrote:
>> The IEEE standard 802.1Qaz (and 802.1Q-2014) specifies four principal
>> transmission selection algorithms: strict priority, credit-based shaper,
>> ETS (bandwidth sharing), and vendor-specific. All these have their
>> corresponding knobs in DCB. But DCB does not have interfaces to configure
>> RED and ECN, unlike Qdiscs.
>>
>> In the Qdisc land, strict priority is implemented by PRIO. Credit-based
>> transmission selection algorithm can then be modeled by having e.g. TBF or
>> CBS Qdisc below some of the PRIO bands. ETS would then be modeled by
>> placing a DRR Qdisc under the last PRIO band.
>>
>> The problem with this approach is that DRR on its own, as well as the
>> combination of PRIO and DRR, are tricky to configure and tricky to offload
>> to 802.1Qaz-compliant hardware. This is due to several reasons:
>>
>> - As any classful Qdisc, DRR supports adding classifiers to decide in which
>>   class to enqueue packets. Unlike PRIO, there's however no fallback in the
>>   form of priomap. A way to achieve classification based on packet priority
>>   is e.g. like this:
>>
>>     # tc filter add dev swp1 root handle 1: \
>> 		basic match 'meta(priority eq 0)' flowid 1:10
>>
>>   Expressing the priomap in this manner however forces drivers to deep dive
>>   into the classifier block to parse the individual rules.
>>
>>   A possible solution would be to extend the classes with a "defmap" a la
>>   split / defmap mechanism of CBQ, and introduce this as a last resort
>>   classification. However, unlike priomap, this doesn't have the guarantee
>>   of covering all priorities. Traffic whose priority is not covered is
>>   dropped by DRR as unclassified. But ASICs tend to implement dropping in
>>   the ACL block, not in scheduling pipelines. The need to treat these
>>   configurations correctly (if only to decide to not offload at all)
>>   complicates a driver.
>>
>>   It's not clear how to retrofit priomap with all its benefits to DRR
>>   without changing it beyond recognition.
>>
>> - The interplay between PRIO and DRR is also causing problems. 802.1Qaz has
>>   all ETS TCs as a last resort. I believe switch ASICs that support ETS at
>>   all will handle ETS traffic likewise. However the Linux model is more
>>   generic, allowing the DRR block in any band. Drivers would need to be
>>   careful to handle this case correctly, otherwise the offloaded model
>>   might not match the slow-path one.
>>
>>   In a similar vein, PRIO and DRR need to agree on the list of priorities
>>   assigned to DRR. This is doubly problematic--the user needs to take care
>>   to keep the two in sync, and the driver needs to watch for any holes in
>>   DRR coverage and treat the traffic correctly, as discussed above.
>>
>>   Note that at the time that DRR Qdisc is added, it has no classes, and
>>   thus any priorities assigned to that PRIO band are not covered. Thus this
>>   case is surprisingly rather common, and needs to be handled gracefully by
>>   the driver.
>>
>> - Similarly due to DRR flexibility, when a Qdisc (such as RED) is attached
>>   below it, it is not immediately clear which TC the class represents. This
>>   is unlike PRIO with its straightforward classid scheme. When DRR is
>>   combined with PRIO, the relationship between classes and TCs gets even
>>   more murky.
>>
>>   This is a problem for users as well: the TC mapping is rather important
>>   for (devlink) shared buffer configuration and (ethtool) counters.
>
> IMHO adding an API to simplify HW config is a double edged sword.
> I think everyone will appreciate the simplicity of the new interface..
> until the HW gets a little more smart and then we'll all have to

For reference, the Spectrum hardware already is more smart. We could
offload PRIO with several DRRs under different bands, the HW is
expressive enough to describe this. But nobody seems to need this: it
seems there are no customers needing anything more than what 802.1Qaz
describes. The DCB interface, which is pretty much married to HW
interfaces, is likewise very close to what 802.1Q specifies, and I don't
believe that's by chance.

> go back to the full interface and offload both that and the simple one,
> or keep growing the new interface (for all practical sense just for HW)
> Qdisc.

If 802.1Q introduces an algorithm that can't be expressed as a single
Qdisc, growing the ETS Qdisc is of course valid. E.g. the shaper
operation is restricted to a single band, so it makes sense to express
it as an independent unit. That's unlike the ETS algorithm, which needs
cooperation between several bands, so you can't easily attach "ETS'ness"
under individual PRIO bands.

> Having written a MQ+GRED offload I sympathize with the complexity
> concerns, also trying to explain how to set up such Qdiscs to users
> results in a lot of blank stares.
>
> Is there any chance at all we could simplify things by adding a better
> user interface and a common translation layer in front of the drivers?

One can imagine a library that handles these sorts of stuff. Drivers
would forward TC events to it, it would figure out what's what, and
somehow signal back to the driver. But packaging this as a Qdisc is such
an interface as well. And because Qdisc interface is well understood not
only by kernel hackers, but also by end users, a Qdisc takes care of
that part of the problem as well.