From 7d1285b6d4ac484c773132b24ab383af2a1ededf Mon Sep 17 00:00:00 2001
From: Rahul <rahul.thakur@iopsys.eu>
Date: Mon, 13 Dec 2021 16:07:24 +0530
Subject: [PATCH] iopsys-brcm63xx-arm: resolve link flap issue

This resolve the wan link flap observed. Suspected race condition
when first trying to set the port speed as 1000FD and then immediately
changing it to auto.

This fix simplifies this logic and also resolves the issue.
---
 .../base-files/lib/network/port.sh            | 22 ++++++++-----------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/iopsys-brcm63xx-arm/base-files/lib/network/port.sh b/iopsys-brcm63xx-arm/base-files/lib/network/port.sh
index f4c627436..d531d7b83 100644
--- a/iopsys-brcm63xx-arm/base-files/lib/network/port.sh
+++ b/iopsys-brcm63xx-arm/base-files/lib/network/port.sh
@@ -56,25 +56,21 @@ set_port_settings() {
 	[ "$duplex" == 0 ] && dplx="HD" || dplx="FD"
 	crossbar="$(echo `ethctl $ifname phy-crossbar` | awk -F' ' '{ print $2 $3 }')"
 
-        if [ "$crossbar" == "oncrossbar" ]; then
-	    crossbarports="$(echo `ethctl $ifname phy-crossbar` | awk -F':' '{ print $NF }')"
+	if [ "$crossbar" == "oncrossbar" ]; then
+		crossbarports="$(echo `ethctl $ifname phy-crossbar` | awk -F':' '{ print $NF }')"
 
-            for subport in $crossbarports; do
-                ethctl $ifname media-type $speed$dplx port $subport &>/dev/null
-            done
-        else
-            ethctl $ifname media-type $speed$dplx &>/dev/null
-        fi
-
-	if [ "$autoneg" == "on" ]; then
-		# If Auto-negotiation is enabled, use ethswctl
-		# utility to advertise all supported speeds
-		if [ "$crossbar" == "oncrossbar" ]; then
+		if [ "$autoneg" == "on" ]; then
 			for subport in $crossbarports; do
 				ethctl $ifname media-type auto port $subport &>/dev/null
 			done
 		else
+			ethctl $ifname media-type $speed$dplx port $subport &>/dev/null
+		fi
+	else
+		if [ "$autoneg" == "on" ]; then
 			ethctl $ifname media-type auto &>/dev/null
+		else
+			ethctl $ifname media-type $speed$dplx &>/dev/null
 		fi
 	fi
 
-- 
GitLab