From 53c03c3550ea9aad78c80291c98b26df816d8f88 Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Wed, 3 Jun 2026 11:12:55 +0530 Subject: [PATCH 1/2] functestlib: suppress noisy Ethernet carrier read failures Some Ethernet drivers can return EINVAL when reading /sys/class/net//carrier while the MAC/PHY attach path is not fully operational. The current Ethernet link polling can leak these cat errors directly into LAVA stdout and obscure the real kernel failure. Update ethIsLinkUp() to suppress carrier read stderr and treat unreadable carrier as unknown, then continue through the existing fallback checks such as is_link_up, operstate, LOWER_UP, and ethtool. This keeps the helper behavior unchanged while making Ethernet CI logs cleaner and easier to triage. Signed-off-by: Srikanth Muppandam --- Runner/utils/functestlib.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index 556226c8..05243a9e 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -2579,39 +2579,46 @@ ethLinkDetected() { ethIsLinkUp() { iface=$1 + carrier="" + st="" + ld="" + [ -n "$iface" ] || return 1 - # 1) If carrier says 1, we are good (fast path) + # 1) If carrier says 1, we are good. + # Some drivers return EINVAL while MAC/PHY attach is broken or incomplete. + # Suppress stderr to avoid noisy LAVA stdout. if [ -r "/sys/class/net/$iface/carrier" ]; then - [ "$(cat "/sys/class/net/$iface/carrier" 2>/dev/null)" = "1" ] && return 0 - # If carrier is 0, do NOT return yet — fall through to other hints. + carrier="$(cat "/sys/class/net/$iface/carrier" 2>/dev/null || true)" + [ "$carrier" = "1" ] && return 0 fi - # 2) If helper exists and says up, accept it (but don't fail early) + # 2) If helper exists and says up, accept it. if command -v is_link_up >/dev/null 2>&1; then - is_link_up "$iface" && return 0 + is_link_up "$iface" >/dev/null 2>&1 && return 0 fi - # 3) operstate can sometimes reflect link sooner than carrier in some stacks + # 3) operstate can sometimes reflect link sooner than carrier. if [ -r "/sys/class/net/$iface/operstate" ]; then - st=$(cat "/sys/class/net/$iface/operstate" 2>/dev/null || true) + st="$(cat "/sys/class/net/$iface/operstate" 2>/dev/null || true)" [ "$st" = "up" ] && return 0 fi - # 4) ip link LOWER_UP (physical) is a good signal if ip exists + # 4) ip link LOWER_UP is a useful physical-link signal. if command -v ip >/dev/null 2>&1; then ip link show "$iface" 2>/dev/null | grep -qw "LOWER_UP" && return 0 fi - # 5) Last resort: ethtool parse + # 5) Last resort: ethtool parse. if command -v ethtool >/dev/null 2>&1; then - ld=$(ethtool "$iface" 2>/dev/null | awk -F': ' '/^[[:space:]]*Link detected:/ {print $2; exit 0}' || true) + ld="$(ethtool "$iface" 2>/dev/null | + awk -F': ' '/^[[:space:]]*Link detected:/ {print $2; exit 0}' || true)" [ "$ld" = "yes" ] && return 0 fi return 1 } - + ethWaitLinkUp() { iface=$1 timeout_s=$2 From c5bcbbe358b308e8dc565d7a787f1bc1c8a81f7f Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Wed, 3 Jun 2026 11:14:12 +0530 Subject: [PATCH 2/2] =?UTF-8?q?Ethernet:=20fail=20on=20MAC/PHY=20errors=20?= =?UTF-8?q?before=20no-link=20skip=20=C2=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Ethernet test currently treats carrier=0 or ethtool "Link detected: no" as a no-cable condition after link bring-up fails. This can hide real driver or device-tree issues where qcom-ethqos/phylink fails before cable detection is meaningful. Add a focused kernel-log scan before classifying no-link as SKIP. If Ethernet MAC/PHY/phylink errors are detected, print the filtered kernel lines to stdout and report FAIL instead of SKIP. This preserves SKIP for clean no-cable/no-carrier cases while correctly flagging failures such as phylink validation errors, 2500base-x mode mismatches, and "cannot attach to PHY" errors. Signed-off-by: Srikanth Muppandam --- Runner/suites/Connectivity/Ethernet/run.sh | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Runner/suites/Connectivity/Ethernet/run.sh b/Runner/suites/Connectivity/Ethernet/run.sh index b34db7b0..a08a2ad3 100755 --- a/Runner/suites/Connectivity/Ethernet/run.sh +++ b/Runner/suites/Connectivity/Ethernet/run.sh @@ -151,6 +151,33 @@ for iface in $ETH_IFACES; do ip link show "$iface" 2>/dev/null | while IFS= read -r l; do [ -n "$l" ] && log_info "[ip-link] $l"; done ethtool "$iface" 2>/dev/null | sed -n '1,80p' | while IFS= read -r l; do [ -n "$l" ] && log_info "[ethtool] $l"; done + eth_dmesg_errors="./${iface}_ethernet_dmesg_errors.log" + rm -f ./dmesg_errors.log ./dmesg_snapshot.log ./dmesg_errors_*.log "$eth_dmesg_errors" 2>/dev/null || true + + log_info "$iface: scanning kernel log for Ethernet MAC/PHY/phylink errors before classifying no-link" + + scan_dmesg_errors \ + "$test_path" \ + "qcom-ethqos|stmmac|phylink|QCA808|qca808|qca808x|2500base|2500base-x|sgmii|xgmac|dwmac" \ + "Link is Down|Link down|Link detected: no|carrier lost|no carrier|Network is down|Register MEM_TYPE_PAGE_POOL" || true + + if [ -s ./dmesg_errors.log ]; then + cp ./dmesg_errors.log "$eth_dmesg_errors" 2>/dev/null || true + + log_fail "$iface: Ethernet driver/PHY errors detected; not treating as no-cable" + log_info "$iface: filtered Ethernet kernel errors follow:" + log_info "$iface: source=$eth_dmesg_errors" + + while IFS= read -r line || [ -n "$line" ]; do + [ -n "$line" ] || continue + log_info "[eth-kernel:$iface] $line" + done < ./dmesg_errors.log + + echo "$iface: FAIL (Ethernet MAC/PHY/phylink kernel errors during link bring-up)" >>"$summary_file" + any_tested=1 + continue + fi + if [ "$carrier" = "0" ]; then log_warn "$iface: no link detected (carrier=0); treating as no-cable and skipping" echo "$iface: SKIP (no cable/link; carrier=0)" >>"$summary_file"