Skip to contentSkip to conversation

utils/net/rtnet.in: add delay during master configuration

PATCH Superseded Mauro S. 2 participants 3 messages Apr 22, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mauro S.

author
#0 lore raw

PATCH 1/1 utils/net/rtnet.in: add delay during master configuration

Some cards are slow to get the connection link up after the "rtifconfig rteth0 up" command, e.g. on an Atom-x5 with an Intel I210 (rt_igb driver) I detected approximately 3 seconds to get the link up.

On master, the "rtifconfig rteth0 up" is followed by TDMA configuration and start. After the TDMA start, the sync packet is sent at the defined cycle time.

Sometimes, after "rtnet start", the dmesg fills with this error:

TDMA: Failed to transmit sync frame!

and the rt driver locks. Then, the kernel watchdog is triggered and the NIC is hw-reset by the kernel, producing more errors and another lock. Sometimes the dmesg only fills with the error message and the NIC does not lock.
This happens because the interface is not up and ready to handle the sync packets when TDMA is started.

This patch introduces a configurable delay between the "rtifconfig rteth0 up" and the TDMA start on master host. This allows to avoid these kind of problems.

Signature · 8 lines
Mauro S.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-utils-net-rtnet.in-add-delay-during-master-configura.patch
Type: text/x-patch
Size: 3060 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20220422/daed78d0/attachment.bin>
#1 lore raw
Quoted 19 lines · Mauro S. via Xenomai

Some cards are slow to get the connection link up after the "rtifconfig rteth0 up" command, e.g. on an Atom-x5 with an Intel I210 (rt_igb driver) I detected approximately 3 seconds to get the link up.

On master, the "rtifconfig rteth0 up" is followed by TDMA configuration and start. After the TDMA start, the sync packet is sent at the defined cycle time.

Sometimes, after "rtnet start", the dmesg fills with this error:

  TDMA: Failed to transmit sync frame!

and the rt driver locks. Then, the kernel watchdog is triggered and the NIC is hw-reset by the kernel, producing more errors and another lock. Sometimes the dmesg only fills with the error message and the NIC does not lock.
This happens because the interface is not up and ready to handle the sync packets when TDMA is started.

Quoted 5 lines

This patch introduces a configurable delay between the "rtifconfig rteth0 up"
and the TDMA start on master host. This allows to avoid these kind of problems.

Thanks for the enhancement! Somehow the patch was attached, rather than inlined, and that results in it being dropped from the distributed emails. So I'm pasting it here.

We need a legal "Signed-off-by" line (https://developercertificate.org/).

Quoted 67 lines
---
 utils/net/rtnet.in | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
utils/net/rtnet.in +19 -2
index f81a7bb0a..8c2dcdf6e 100644
@@ -15,15 +15,19 @@ debug_func() {
 usage() {
     cat << EOF
 Usage:
-    $0 [-cf <config-file>] [-v] [-c] {start|stop}
+    $0 [-cf <config-file>] [-d <delay>] [-v] [-c] {start|stop}
 	Start or stop station according to configuration file
 
-    $0 [-cf <config-file>] [-v] [-c] master <slave_ip1> [<slave_ip2> ...]
+    $0 [-cf <config-file>] [-d <delay>] [-v] [-c] master <slave_ip1> [<slave_ip2> ...]
 	Start station as master for given list of slaves
 
     $0 [-cf <config-file>] [-v] capture
 	Start only passive realtime capturing
 
+    The parameter -d allows to introduce a delay in seconds between the
+	"rtifconfig rtethX up" command and the TDMA start on the host
+	configured as master. Useful to avoid errors/card locks when the
+	RT NIC is slow to get the link up.
     The additional switch -v enables verbose output.
     The additional switch -c enables capturing mode to allow use of a network
 	analyzer such as Wireshark (if rtnet was built with --enable-rtcap).
@@ -76,6 +80,10 @@ submit_cfg() {
 	master)
 	    $RTIFCONFIG rteth0 up $STATION_IP
 
+	    if [ -n "$UPDELAY" ]; then
+		sleep $UPDELAY
+	    fi
+
 	    $TDMACFG rteth0 master $TDMA_CYCLE
 	    eval "$TDMA_SLOTS"
 
@@ -144,6 +152,10 @@ start_master() {
 
 	$RTIFCONFIG rteth0 up $IPADDR $NETMASK_OPT
 
+	if [ -n "$UPDELAY" ]; then
+	    sleep $UPDELAY
+	fi
+
 	$TDMACFG rteth0 master $TDMA_CYCLE
 	$TDMACFG rteth0 slot 0 0
 
@@ -258,6 +270,11 @@ else
     exit 1
 fi
 
+if [ "$1" = "-d" ]; then
+    UPDELAY="$2"
+    shift 2
+fi
+
 if [ "$1" = "-v" ]; then
     echo "Turning on verbose mode"
     RTIFCONFIG="debug_func $RTIFCONFIG"
Signature · 1 line
2.17.1

Pragmatic approach, I'm fine with it - as we have no proper interface to read back the current link state (at least as far as I remember).

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
author
#2 lore raw

Il 22/04/22 18:55, Jan Kiszka ha scritto:

Quoted 26 lines · Mauro S. via Xenomai
Quoted 19 lines

Some cards are slow to get the connection link up after the "rtifconfig rteth0 up" command, e.g. on an Atom-x5 with an Intel I210 (rt_igb driver) I detected approximately 3 seconds to get the link up.

On master, the "rtifconfig rteth0 up" is followed by TDMA configuration and start. After the TDMA start, the sync packet is sent at the defined cycle time.

Sometimes, after "rtnet start", the dmesg fills with this error:

  TDMA: Failed to transmit sync frame!

and the rt driver locks. Then, the kernel watchdog is triggered and the NIC is hw-reset by the kernel, producing more errors and another lock. Sometimes the dmesg only fills with the error message and the NIC does not lock.
This happens because the interface is not up and ready to handle the sync packets when TDMA is started.

Quoted 5 lines

This patch introduces a configurable delay between the "rtifconfig rteth0 up"
and the TDMA start on master host. This allows to avoid these kind of problems.

Quoted 3 lines

Thanks for the enhancement! Somehow the patch was attached, rather than inlined, and that results in it being dropped from the distributed emails. So I'm pasting it here.

Yes, my mistake sorry.

Quoted 2 lines

We need a legal "Signed-off-by" line (https://developercertificate.org/).

Another mistake, double sorry. I resend the patch inlined and signed-off.

Quoted 57 lines
Quoted 57 lines
---
  utils/net/rtnet.in | 21 +++++++++++++++++++--
  1 file changed, 19 insertions(+), 2 deletions(-)
utils/net/rtnet.in +14 -2
index f81a7bb0a..8c2dcdf6e 100644
@@ -15,15 +15,19 @@ debug_func() {
  usage() {
      cat << EOF
  Usage:
-    $0 [-cf <config-file>] [-v] [-c] {start|stop}
+    $0 [-cf <config-file>] [-d <delay>] [-v] [-c] {start|stop}
  	Start or stop station according to configuration file
 
-    $0 [-cf <config-file>] [-v] [-c] master <slave_ip1> [<slave_ip2> ...]
+    $0 [-cf <config-file>] [-d <delay>] [-v] [-c] master <slave_ip1> [<slave_ip2> ...]
  	Start station as master for given list of slaves
 
      $0 [-cf <config-file>] [-v] capture
  	Start only passive realtime capturing
 
+    The parameter -d allows to introduce a delay in seconds between the
+	"rtifconfig rtethX up" command and the TDMA start on the host
+	configured as master. Useful to avoid errors/card locks when the
+	RT NIC is slow to get the link up.
      The additional switch -v enables verbose output.
      The additional switch -c enables capturing mode to allow use of a network
  	analyzer such as Wireshark (if rtnet was built with --enable-rtcap).
@@ -76,6 +80,10 @@ submit_cfg() {
  	master)
  	    $RTIFCONFIG rteth0 up $STATION_IP
 
+	    if [ -n "$UPDELAY" ]; then
+		sleep $UPDELAY
+	    fi
+
  	    $TDMACFG rteth0 master $TDMA_CYCLE
  	    eval "$TDMA_SLOTS"
 
@@ -144,6 +152,10 @@ start_master() {
 
  	$RTIFCONFIG rteth0 up $IPADDR $NETMASK_OPT
 
+	if [ -n "$UPDELAY" ]; then
+	    sleep $UPDELAY
+	fi
+
  	$TDMACFG rteth0 master $TDMA_CYCLE
  	$TDMACFG rteth0 slot 0 0
 
@@ -258,6 +270,11 @@ else
      exit 1
  fi
 
Quoted 14 lines
Quoted 11 lines
utils/net/rtnet.in +5 -0
+if [ "$1" = "-d" ]; then
+    UPDELAY="$2"
+    shift 2
+fi
+
  if [ "$1" = "-v" ]; then
      echo "Turning on verbose mode"
      RTIFCONFIG="debug_func $RTIFCONFIG"
Signature · 1 line
2.17.1

Pragmatic approach, I'm fine with it - as we have no proper interface to read back the current link state (at least as far as I remember).

Yes, you are right: I tried to find some mechanism (like "carrier" file) in /sys and /proc but I found nothing.

Quoted 3 lines

Jan

Signature · 1 line
Mauro S.