[net-next,1/3] net/sched: taprio: fix calculation of maximum gate durations

Message ID 20230215224632.2532685-2-vladimir.oltean@nxp.com
State New
Headers
Series taprio queueMaxSDU fixes |

Commit Message

Vladimir Oltean Feb. 15, 2023, 10:46 p.m. UTC
  taprio_calculate_gate_durations() depends on netdev_get_num_tc() and
this returns 0. So it calculates the maximum gate durations for no
traffic class.

I had tested the blamed commit only with another patch in my tree, one
which in the end I decided isn't valuable enough to submit ("net/sched:
taprio: mask off bits in gate mask that exceed number of TCs").

The problem is that having this patch threw off my testing. By moving
the netdev_set_num_tc() call earlier, we implicitly gave to
taprio_calculate_gate_durations() the information it needed.

Extract only the portion from the unsubmitted change which applies the
mqprio configuration to the netdev earlier.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230130173145.475943-15-vladimir.oltean@nxp.com/
Fixes: a306a90c8ffe ("net/sched: taprio: calculate tc gate durations")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/sched/sch_taprio.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
  

Comments

Kurt Kanzenbach Feb. 16, 2023, 9:27 a.m. UTC | #1
On Thu Feb 16 2023, Vladimir Oltean wrote:
> taprio_calculate_gate_durations() depends on netdev_get_num_tc() and
> this returns 0. So it calculates the maximum gate durations for no
> traffic class.
>
> I had tested the blamed commit only with another patch in my tree, one
> which in the end I decided isn't valuable enough to submit ("net/sched:
> taprio: mask off bits in gate mask that exceed number of TCs").
>
> The problem is that having this patch threw off my testing. By moving
> the netdev_set_num_tc() call earlier, we implicitly gave to
> taprio_calculate_gate_durations() the information it needed.
>
> Extract only the portion from the unsubmitted change which applies the
> mqprio configuration to the netdev earlier.
>
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230130173145.475943-15-vladimir.oltean@nxp.com/
> Fixes: a306a90c8ffe ("net/sched: taprio: calculate tc gate durations")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
  

Patch

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 9781b47962bb..556e72ec0f38 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1833,23 +1833,6 @@  static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
 		goto free_sched;
 	}
 
-	err = parse_taprio_schedule(q, tb, new_admin, extack);
-	if (err < 0)
-		goto free_sched;
-
-	if (new_admin->num_entries == 0) {
-		NL_SET_ERR_MSG(extack, "There should be at least one entry in the schedule");
-		err = -EINVAL;
-		goto free_sched;
-	}
-
-	err = taprio_parse_clockid(sch, tb, extack);
-	if (err < 0)
-		goto free_sched;
-
-	taprio_set_picos_per_byte(dev, q);
-	taprio_update_queue_max_sdu(q, new_admin, stab);
-
 	if (mqprio) {
 		err = netdev_set_num_tc(dev, mqprio->num_tc);
 		if (err)
@@ -1867,6 +1850,23 @@  static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
 					       mqprio->prio_tc_map[i]);
 	}
 
+	err = parse_taprio_schedule(q, tb, new_admin, extack);
+	if (err < 0)
+		goto free_sched;
+
+	if (new_admin->num_entries == 0) {
+		NL_SET_ERR_MSG(extack, "There should be at least one entry in the schedule");
+		err = -EINVAL;
+		goto free_sched;
+	}
+
+	err = taprio_parse_clockid(sch, tb, extack);
+	if (err < 0)
+		goto free_sched;
+
+	taprio_set_picos_per_byte(dev, q);
+	taprio_update_queue_max_sdu(q, new_admin, stab);
+
 	if (FULL_OFFLOAD_IS_ENABLED(q->flags))
 		err = taprio_enable_offload(dev, q, new_admin, extack);
 	else