Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 46 additions & 139 deletions Runner/suites/Connectivity/WiFi/WiFi_Firmware_Driver/run.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause
# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SCRIPT_DIR="$(
cd "$(dirname "$0")" || exit 1
pwd
)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"

while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
Expand All @@ -19,180 +22,84 @@ if [ -z "$INIT_ENV" ]; then
exit 1
fi

# Only source if not already loaded (idempotent)
if [ -z "$__INIT_ENV_LOADED" ]; then
if [ -z "${__INIT_ENV_LOADED:-}" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi

# Always source functestlib.sh, using $TOOLS exported by init_env
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"
# shellcheck disable=SC1090,SC1091
. "$TOOLS/lib_connectivity.sh"

TESTNAME="WiFi_Firmware_Driver"
test_path=$(find_test_case_by_name "$TESTNAME")
test_path="$(find_test_case_by_name "$TESTNAME")"
cd "$test_path" || exit 1

RES_FILE="./${TESTNAME}.res"
WIFI_FW_PROBE_LOG_DIR="${WIFI_FW_PROBE_LOG_DIR:-./wifi_firmware_driver_dmesg}"
WIFI_FW_PROBE_LOG_TAG="${WIFI_FW_PROBE_LOG_TAG:-${TESTNAME}/probe}"
WIFI_FW_LOAD_LOG_TAG="${WIFI_FW_LOAD_LOG_TAG:-${TESTNAME}/firmware}"

: >"$RES_FILE"

log_info "--------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
log_info "=== Test Initialization ==="
log_info "Probe log tag: $WIFI_FW_PROBE_LOG_TAG"
log_info "Firmware log tag: $WIFI_FW_LOAD_LOG_TAG"

if ! check_dependencies find grep modprobe lsmod cat stat; then
log_skip "$TESTNAME SKIP - required tools (find/grep/modprobe/lsmod/cat/stat) missing"
if ! check_dependencies find grep modprobe lsmod cat stat awk; then
log_skip "$TESTNAME SKIP - required tools (find/grep/modprobe/lsmod/cat/stat/awk) missing"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
fi

# Detect SoC from /proc/device-tree/model
if [ -f /proc/device-tree/model ]; then
read -r soc_model < /proc/device-tree/model
read -r soc_model </proc/device-tree/model
else
soc_model="Unknown"
fi
log_info "Detected SoC model: $soc_model"

# ---------------------------------------------------------------------------
# Firmware detection: support ath11k (amss.bin / wpss.mbn) and ath10k (WCN3990)
# ---------------------------------------------------------------------------
log_info "Scanning for WiFi firmware (ath11k / ath10k)..."

fwfile=""
wifi_family=""

# Prefer ath11k if present (Lemans/Monaco/Kodiak type platforms)
if [ -d /lib/firmware/ath11k ]; then
if find /lib/firmware/ath11k/ -type f -name "amss.bin" -print -quit 2>/dev/null | grep -q .; then
fwfile=$(find /lib/firmware/ath11k/ -type f -name "amss.bin" -print -quit 2>/dev/null)
wifi_family="ath11k"
elif find /lib/firmware/ath11k/ -type f -name "wpss.mbn" -print -quit 2>/dev/null | grep -q .; then
fwfile=$(find /lib/firmware/ath11k/ -type f -name "wpss.mbn" -print -quit 2>/dev/null)
wifi_family="ath11k"
fi
fi
log_info "Detected SoC model: $soc_model"

# If no ath11k firmware found, try ath10k (e.g. WCN3990 on RB1/QCM2290)
if [ -z "$fwfile" ] && [ -d /lib/firmware/ath10k ]; then
# Look for wlan firmware or generic firmware-*.bin
if find /lib/firmware/ath10k/ -type f -name "wlanmdsp.mbn" -print -quit 2>/dev/null | grep -q .; then
fwfile=$(find /lib/firmware/ath10k/ -type f -name "wlanmdsp.mbn" -print -quit 2>/dev/null)
wifi_family="ath10k"
elif find /lib/firmware/ath10k/ -type f -name "firmware-*.bin" -print -quit 2>/dev/null | grep -q .; then
fwfile=$(find /lib/firmware/ath10k/ -type f -name "firmware-*.bin" -print -quit 2>/dev/null)
wifi_family="ath10k"
fi
fi
suite_rc=0

if [ -z "$fwfile" ] || [ -z "$wifi_family" ]; then
log_skip "$TESTNAME SKIP - No ath11k/ath10k WiFi firmware found under /lib/firmware (ath11k or ath10k)"
log_info "=== WiFi Firmware Detection ==="
if ! wifi_detect_firmware_info; then
log_skip "$TESTNAME SKIP - No ath12k/ath11k/ath10k WiFi firmware found under /lib/firmware"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
fi

size=$(stat -c%s "$fwfile" 2>/dev/null)
basename=$(basename "$fwfile")
log_info "Detected WiFi firmware family: $wifi_family"
log_info "Detected firmware [$basename]: $fwfile (size: $size bytes)"
log_info "Detected WiFi firmware family: $WIFI_FW_FAMILY"
log_info "Detected firmware [$WIFI_FW_BASENAME]: $WIFI_FW_FILE (size: $WIFI_FW_SIZE bytes)"

suite_rc=0
log_info "=== Family-specific Runtime Preparation ==="
if ! wifi_handle_firmware_family "$WIFI_FW_FAMILY" "$WIFI_FW_BASENAME"; then
suite_rc=1
fi

# ---------------------------------------------------------------------------
# Family-specific handling (load / validate) – use log_* only, decide at end
# ---------------------------------------------------------------------------
case "$wifi_family" in
ath11k)
case "$basename" in
wpss.mbn)
log_info "Platform using wpss.mbn firmware (e.g., Kodiak - WPSS via remoteproc)"
if validate_remoteproc_running "wpss"; then
log_info "Remoteproc 'wpss' is active and validated."
else
log_fail "Remoteproc 'wpss' validation failed."
suite_rc=1
fi
log_info "No ath11k_pci module load needed for wpss-based platform."
;;
amss.bin)
log_info "amss.bin firmware detected (e.g., WCN6855 - Lemans/Monaco via ath11k_pci)"
if ! modprobe ath11k_pci 2>/dev/null; then
log_fail "Failed to load ath11k_pci module."
suite_rc=1
else
log_info "ath11k_pci module loaded successfully."
fi
;;
*)
log_skip "$TESTNAME SKIP - Unsupported ath11k firmware type: $basename"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
;;
esac
;;
ath10k)
log_info "ath10k firmware detected (e.g., WCN3990 on RB1/QCM2290)."
# Ensure ath10k_core + one of the bus drivers (snoc/pci/sdio) are loaded
if ! lsmod | grep -q '^ath10k_core\s'; then
log_info "ath10k_core not loaded yet; attempting to load ath10k bus drivers..."
bus_loaded=0
for m in ath10k_snoc ath10k_pci ath10k_sdio; do
if modprobe "$m" 2>/dev/null; then
log_info "Loaded ath10k bus driver module: $m"
bus_loaded=1
break
fi
done
if [ "$bus_loaded" -ne 1 ]; then
log_fail "Failed to load any ath10k bus driver (ath10k_snoc/ath10k_pci/ath10k_sdio)."
suite_rc=1
fi
else
log_info "ath10k_core already loaded; skipping bus driver modprobe attempts."
fi
;;
*)
log_skip "$TESTNAME SKIP - Unsupported WiFi family detected: $wifi_family"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
;;
esac

# ---------------------------------------------------------------------------
# Module visibility checks (family-specific) – explicitly verify ath10k modules
# ---------------------------------------------------------------------------
if [ "$wifi_family" = "ath11k" ]; then
log_info "Checking active ath11k-related kernel modules via lsmod..."
if lsmod | grep -Eq '^ath11k(_.*)?\s'; then
lsmod | grep -E '^ath11k(_.*)?\s' | while read -r mod_line; do
log_info " Module loaded: $mod_line"
done
else
log_fail "No ath11k-related kernel module detected via lsmod."
suite_rc=1
fi
elif [ "$wifi_family" = "ath10k" ]; then
log_info "Checking active ath10k-related kernel modules via lsmod..."
if lsmod | grep -q '^ath10k_core\s'; then
log_info " Core module loaded: ath10k_core"
else
log_fail "ath10k_core module is not loaded."
suite_rc=1
fi
log_info "=== Family-specific Module Visibility ==="
if ! wifi_verify_family_modules "$WIFI_FW_FAMILY"; then
suite_rc=1
fi

if lsmod | grep -Eq '^ath10k_(snoc|pci|sdio)\s'; then
lsmod | grep -E '^ath10k_(snoc|pci|sdio)\s' | while read -r mod_line; do
log_info " Bus driver loaded: $mod_line"
done
else
log_fail "No ath10k bus driver module (ath10k_snoc/ath10k_pci/ath10k_sdio) detected via lsmod."
suite_rc=1
fi
log_info "=== WiFi Firmware Load Evidence ==="
if wifi_firmware_loaded "$WIFI_FW_FAMILY" "$WIFI_FW_LOAD_LOG_TAG"; then
log_pass "[$WIFI_FW_LOAD_LOG_TAG] Firmware load/use evidence found."
else
log_fail "[$WIFI_FW_LOAD_LOG_TAG] Firmware load/use evidence not found."
suite_rc=1
fi

log_info "=== WiFi Probe Check ==="
if wifi_has_probe_failures "$WIFI_FW_PROBE_LOG_DIR" "$WIFI_FW_PROBE_LOG_TAG"; then
suite_rc=1
else
log_pass "[$WIFI_FW_PROBE_LOG_TAG] No WiFi probe/runtime failures detected in kernel log."
fi

# ---------------------------------------------------------------------------
# Final result
# ---------------------------------------------------------------------------
if [ "$suite_rc" -eq 0 ]; then
log_pass "$TESTNAME: PASS - WiFi firmware and driver validation successful."
echo "$TESTNAME PASS" >"$RES_FILE"
Expand Down
Loading
Loading