Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: tsn_lib: add window_size argument to isochron_do()

Make out-of-band testing (send a packet when its traffic class gate is
closed, expecting it to be delayed) more predictable by allowing the
window size to be customized by isochron_do().

From man isochron-send, the window size alters the advance time (the
delta between the transmission time of the packet, and its expected TX
time when using SO_TXTIME or tc-taprio on the sender). In absence of the
argument, isochron-send defaults to maximizing the advance time (making
it equal to the cycle length).

The default behavior is exactly what is problematic. An advance time
that is too large will make packets intended to be out-of-band still be
potentially in-band with an open gate from the schedule's previous cycle.
We need to allow that advance time to be reduced.

Perhaps a bit confusingly, isochron_do() has a shift_time argument
currently, but that does not help here. The shift time shifts both the
user space wakeup time and the expected TX time by equal amounts, it is
unable of bringing them closer to one another.

Set the window size properly for the Ocelot PSFP selftest as well.
That used to work due to a very carefully chosen SHIFT_TIME_NS.
I've re-tested that the test still works properly.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20250426144859.3128352-4-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
f52fe6ef efa6eb7d

+6
+1
tools/testing/selftests/drivers/net/ocelot/psfp.sh
··· 266 266 "${base_time}" \ 267 267 "${CYCLE_TIME_NS}" \ 268 268 "${SHIFT_TIME_NS}" \ 269 + "${GATE_DURATION_NS}" \ 269 270 "${NUM_PKTS}" \ 270 271 "${STREAM_VID}" \ 271 272 "${STREAM_PRIO}" \
+5
tools/testing/selftests/net/forwarding/tsn_lib.sh
··· 182 182 local base_time=$1; shift 183 183 local cycle_time=$1; shift 184 184 local shift_time=$1; shift 185 + local window_size=$1; shift 185 186 local num_pkts=$1; shift 186 187 local vid=$1; shift 187 188 local priority=$1; shift ··· 211 210 212 211 if ! [ -z "${shift_time}" ]; then 213 212 extra_args="${extra_args} --shift-time=${shift_time}" 213 + fi 214 + 215 + if ! [ -z "${window_size}" ]; then 216 + extra_args="${extra_args} --window-size=${window_size}" 214 217 fi 215 218 216 219 if [ "${use_l2}" = "true" ]; then