Skip to content

Commit 7e4babf

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: felix: fix min gate len calculation for tc when its first gate is closed
min_gate_len[tc] is supposed to track the shortest interval of continuously open gates for a traffic class. For example, in the following case: TC 76543210 t0 00000001b 200000 ns t1 00000010b 200000 ns min_gate_len[0] and min_gate_len[1] should be 200000, while min_gate_len[2-7] should be 0. However what happens is that min_gate_len[0] is 200000, but min_gate_len[1] ends up being 0 (despite gate_len[1] being 200000 at the point where the logic detects the gate close event for TC 1). The problem is that the code considers a "gate close" event whenever it sees that there is a 0 for that TC (essentially it's level rather than edge triggered). By doing that, any time a gate is seen as closed without having been open prior, gate_len, which is 0, will be written into min_gate_len. Once min_gate_len becomes 0, it's impossible for it to track anything higher than that (the length of actually open intervals). To fix this, we make the writing to min_gate_len[tc] be edge-triggered, which avoids writes for gates that are closed in consecutive intervals. However what this does is it makes us need to special-case the permanently closed gates at the end. Fixes: 55a515b ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://lore.kernel.org/r/20220804202817.1677572-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 944e594 commit 7e4babf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/net/dsa/ocelot/felix_vsc9959.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ static void vsc9959_tas_min_gate_lengths(struct tc_taprio_qopt_offload *taprio,
11371137
{
11381138
struct tc_taprio_sched_entry *entry;
11391139
u64 gate_len[OCELOT_NUM_TC];
1140+
u8 gates_ever_opened = 0;
11401141
int tc, i, n;
11411142

11421143
/* Initialize arrays */
@@ -1164,16 +1165,28 @@ static void vsc9959_tas_min_gate_lengths(struct tc_taprio_qopt_offload *taprio,
11641165
for (tc = 0; tc < OCELOT_NUM_TC; tc++) {
11651166
if (entry->gate_mask & BIT(tc)) {
11661167
gate_len[tc] += entry->interval;
1168+
gates_ever_opened |= BIT(tc);
11671169
} else {
11681170
/* Gate closes now, record a potential new
11691171
* minimum and reinitialize length
11701172
*/
1171-
if (min_gate_len[tc] > gate_len[tc])
1173+
if (min_gate_len[tc] > gate_len[tc] &&
1174+
gate_len[tc])
11721175
min_gate_len[tc] = gate_len[tc];
11731176
gate_len[tc] = 0;
11741177
}
11751178
}
11761179
}
1180+
1181+
/* min_gate_len[tc] actually tracks minimum *open* gate time, so for
1182+
* permanently closed gates, min_gate_len[tc] will still be U64_MAX.
1183+
* Therefore they are currently indistinguishable from permanently
1184+
* open gates. Overwrite the gate len with 0 when we know they're
1185+
* actually permanently closed, i.e. after the loop above.
1186+
*/
1187+
for (tc = 0; tc < OCELOT_NUM_TC; tc++)
1188+
if (!(gates_ever_opened & BIT(tc)))
1189+
min_gate_len[tc] = 0;
11771190
}
11781191

11791192
/* Update QSYS_PORT_MAX_SDU to make sure the static guard bands added by the

0 commit comments

Comments
 (0)