Commit 49919312 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'improve-tsn_lib-selftests-for-future-distributed-tasks'

Vladimir Oltean says:

====================
Improve tsn_lib selftests for future distributed tasks

Some of the boards I am working with are limited in the number of ports
that they offer, and as more TSN related selftests are added, it is
important to be able to distribute the work among multiple boards.
A large part of implementing that is ensuring network-wide
synchronization, but also permitting more streams of data to flow
through the network. There is the more important aspect of also
coordinating the timing characteristics of those streams, and that is
also something that is tackled, although not in this modest patch set.
The goal here is not to introduce new selftests yet, but just to lay a
better foundation for them. These patches are a part of the cleanup work
I've done while working on selftests for frame preemption. They are
regression-tested with psfp.sh.
====================

Link: https://lore.kernel.org/r/20220923210016.3406301-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents bb65131b 162d52df
......@@ -181,7 +181,7 @@ setup_prepare()
# Set up swp1 as a master PHC for h1, synchronized to the local
# CLOCK_REALTIME.
phc2sys_start ${swp1} ${UDS_ADDRESS_SWP1}
phc2sys_start ${UDS_ADDRESS_SWP1}
# Assumption true for LS1028A: h1 and h2 use the same PHC. So by
# synchronizing h1 to swp1 via PTP, h2 is also implicitly synchronized
......
......@@ -22,8 +22,7 @@ fi
phc2sys_start()
{
local if_name=$1
local uds_address=$2
local uds_address=$1
local extra_args=""
if ! [ -z "${uds_address}" ]; then
......@@ -33,9 +32,7 @@ phc2sys_start()
phc2sys_log="$(mktemp)"
chrt -f 10 phc2sys -m \
-c ${if_name} \
-s CLOCK_REALTIME \
-O ${UTC_TAI_OFFSET} \
-a -rr \
--step_threshold 0.00002 \
--first_step_threshold 0.00002 \
${extra_args} \
......@@ -53,15 +50,27 @@ phc2sys_stop()
rm "${phc2sys_log}" 2> /dev/null
}
# Replace space separators from interface list with underscores
if_names_to_label()
{
local if_name_list="$1"
echo "${if_name_list/ /_}"
}
ptp4l_start()
{
local if_name=$1
local if_names="$1"
local slave_only=$2
local uds_address=$3
local log="ptp4l_log_${if_name}"
local pid="ptp4l_pid_${if_name}"
local log="ptp4l_log_$(if_names_to_label ${if_names})"
local pid="ptp4l_pid_$(if_names_to_label ${if_names})"
local extra_args=""
for if_name in ${if_names}; do
extra_args="${extra_args} -i ${if_name}"
done
if [ "${slave_only}" = true ]; then
extra_args="${extra_args} -s"
fi
......@@ -71,7 +80,6 @@ ptp4l_start()
declare -g "${log}=$(mktemp)"
chrt -f 10 ptp4l -m -2 -P \
-i ${if_name} \
--step_threshold 0.00002 \
--first_step_threshold 0.00002 \
--tx_timestamp_timeout 100 \
......@@ -80,16 +88,16 @@ ptp4l_start()
> "${!log}" 2>&1 &
declare -g "${pid}=$!"
echo "ptp4l for interface ${if_name} logs to ${!log} and has pid ${!pid}"
echo "ptp4l for interfaces ${if_names} logs to ${!log} and has pid ${!pid}"
sleep 1
}
ptp4l_stop()
{
local if_name=$1
local log="ptp4l_log_${if_name}"
local pid="ptp4l_pid_${if_name}"
local if_names="$1"
local log="ptp4l_log_$(if_names_to_label ${if_names})"
local pid="ptp4l_pid_$(if_names_to_label ${if_names})"
{ kill ${!pid} && wait ${!pid}; } 2> /dev/null
rm "${!log}" 2> /dev/null
......@@ -136,10 +144,12 @@ isochron_recv_start()
{
local if_name=$1
local uds=$2
local extra_args=$3
local stats_port=$3
local extra_args=$4
local pid="isochron_pid_${stats_port}"
if ! [ -z "${uds}" ]; then
extra_args="--unix-domain-socket ${uds}"
extra_args="${extra_args} --unix-domain-socket ${uds}"
fi
isochron rcv \
......@@ -147,16 +157,20 @@ isochron_recv_start()
--sched-priority 98 \
--sched-fifo \
--utc-tai-offset ${UTC_TAI_OFFSET} \
--stats-port ${stats_port} \
--quiet \
${extra_args} & \
isochron_pid=$!
declare -g "${pid}=$!"
sleep 1
}
isochron_recv_stop()
{
{ kill ${isochron_pid} && wait ${isochron_pid}; } 2> /dev/null
local stats_port=$1
local pid="isochron_pid_${stats_port}"
{ kill ${!pid} && wait ${!pid}; } 2> /dev/null
}
isochron_do()
......@@ -208,7 +222,7 @@ isochron_do()
cpufreq_max ${ISOCHRON_CPU}
isochron_recv_start "${h2}" "${receiver_uds}" "${receiver_extra_args}"
isochron_recv_start "${h2}" "${receiver_uds}" 5000 "${receiver_extra_args}"
isochron send \
--interface ${sender_if_name} \
......@@ -229,7 +243,7 @@ isochron_do()
${extra_args} \
--quiet
isochron_recv_stop
isochron_recv_stop 5000
cpufreq_restore ${ISOCHRON_CPU}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment