net/sched: taprio: don't allow dynamic max_sdu to go negative after stab adjustment
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 15 Feb 2023 22:46:31 +0000 (00:46 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Mon, 20 Feb 2023 07:46:57 +0000 (08:46 +0100)
commitbdf366bd867c4565b535a5825df7ddcb4773fc28
treeb8340300f9126da0ee4725605da45cab81965cb2
parent09dbdf28f9f9fa27e16895c67fbd94ff36124766
net/sched: taprio: don't allow dynamic max_sdu to go negative after stab adjustment

The overhead specified in the size table comes from the user. With small
time intervals (or gates always closed), the overhead can be larger than
the max interval for that traffic class, and their difference is
negative.

What we want to happen is for max_sdu_dynamic to have the smallest
non-zero value possible (1) which means that all packets on that traffic
class are dropped on enqueue. However, since max_sdu_dynamic is u32, a
negative is represented as a large value and oversized dropping never
happens.

Use max_t with int to force a truncation of max_frm_len to no smaller
than dev->hard_header_len + 1, which in turn makes max_sdu_dynamic no
smaller than 1.

Fixes: fed87cc6718a ("net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/sched/sch_taprio.c