Skip to content

Commit 5652e63

Browse files
vcgomesdavem330
authored andcommitted
taprio: Fix enabling offload with wrong number of traffic classes
If the driver implementing taprio offloading depends on the value of the network device number of traffic classes (dev->num_tc) for whatever reason, it was going to receive the value zero. The value was only set after the offloading function is called. So, moving setting the number of traffic classes to before the offloading function is called fixes this issue. This is safe because this only happens when taprio is instantiated (we don't allow this configuration to be changed without first removing taprio). Fixes: 9c66d15 ("taprio: Add support for hardware offloading") Reported-by: Po Liu <[email protected]> Signed-off-by: Vinicius Costa Gomes <[email protected]> Acked-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent de34d70 commit 5652e63

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

net/sched/sch_taprio.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,19 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
14441444

14451445
taprio_set_picos_per_byte(dev, q);
14461446

1447+
if (mqprio) {
1448+
netdev_set_num_tc(dev, mqprio->num_tc);
1449+
for (i = 0; i < mqprio->num_tc; i++)
1450+
netdev_set_tc_queue(dev, i,
1451+
mqprio->count[i],
1452+
mqprio->offset[i]);
1453+
1454+
/* Always use supplied priority mappings */
1455+
for (i = 0; i <= TC_BITMASK; i++)
1456+
netdev_set_prio_tc_map(dev, i,
1457+
mqprio->prio_tc_map[i]);
1458+
}
1459+
14471460
if (FULL_OFFLOAD_IS_ENABLED(taprio_flags))
14481461
err = taprio_enable_offload(dev, mqprio, q, new_admin, extack);
14491462
else
@@ -1471,19 +1484,6 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
14711484
q->advance_timer.function = advance_sched;
14721485
}
14731486

1474-
if (mqprio) {
1475-
netdev_set_num_tc(dev, mqprio->num_tc);
1476-
for (i = 0; i < mqprio->num_tc; i++)
1477-
netdev_set_tc_queue(dev, i,
1478-
mqprio->count[i],
1479-
mqprio->offset[i]);
1480-
1481-
/* Always use supplied priority mappings */
1482-
for (i = 0; i <= TC_BITMASK; i++)
1483-
netdev_set_prio_tc_map(dev, i,
1484-
mqprio->prio_tc_map[i]);
1485-
}
1486-
14871487
if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) {
14881488
q->dequeue = taprio_dequeue_offload;
14891489
q->peek = taprio_peek_offload;

0 commit comments

Comments
 (0)