Re: [PATCH net-next 04/13] net/sched: taprio: allow user input of per-tc max SDU

Vinicius Costa Gomes
2022-09-14T23:00:24Z

Vladimir Oltean <vladimir.oltean@nxp.com> writes:

> On Wed, Sep 14, 2022 at 02:43:02PM -0700, Vinicius Costa Gomes wrote:
>> > @@ -416,6 +417,9 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch,
>> > struct Qdisc *child, struct sk_buff **to_free)
>> > {
>> > struct taprio_sched *q = qdisc_priv(sch);
>> > + struct net_device *dev = qdisc_dev(sch);
>> > + int prio = skb->priority;
>> > + u8 tc;
>> >
>> > /* sk_flags are only safe to use on full sockets. */
>> > if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) {
>> > @@ -427,6 +431,12 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch,
>> > return qdisc_drop(skb, sch, to_free);
>> > }
>> >
>> > + /* Devices with full offload are expected to honor this in hardware */
>> > + tc = netdev_get_prio_tc_map(dev, prio);
>> > + if (q->max_sdu[tc] &&
>> > + q->max_sdu[tc] < max_t(int, 0, skb->len - skb_mac_header_len(skb)))
>> > + return qdisc_drop(skb, sch, to_free);
>> > +
>>
>> One minor idea, perhaps if you initialize q->max_sdu[] with a value that
>> you could use to compare here (2^32 - 1), this comparison could be
>> simplified. The issue is that that value would become invalid for a
>> maximum SDU, not a problem for ethernet.
>
> Could do (and the fact that U32_MAX becomes a reserved value shouldn't
> be a problem for any linklayer), but if I optimize the code for this one
> place, I need, in turn, to increase the complexity in the netlink dump
> and in the offload procedures, to hide what I've done.

Hm, I just noticed something.

During parse the user only sets the max-sdu for the traffic classes she
is interested on. During dump you are showing all of them, the unset
ones will be shown as zero, that seems a bit confusing, which could mean
that you would have to add some checks anyway.

For the offload side, you could just document that U32_MAX means unset.

>
> If I look at the difference in generated code, maybe it's worth it
> (I get rid of a "cbz" instruction). Maybe it's worth simply creating a
> shadow array of q->max_sdu[], but which is also adjusted for something
> like dev->hard_header_len (also a fast path invariant)? This way, we
> could only check for q->max_frm_len[tc] > skb->len and save even more
> checks in the fast path.

--
Vinicius