Skip to contentSkip to conversation

wifi: wlcore: fix junk station signal on wl18xx after association

PATCH New Leav Oz-Ari 1 participant 3 messages Dec 3 TI wilink wireless drivers

lore
Share & tools
lore
#0 lore raw

v2 cover wifi: wlcore: fix junk station signal on wl18xx after association

On wl18xx, the station signal after association comes from a FW beacon RSSI average. Before the first beacon it reads 0 dBm or about -128 dBm. It then restarts at about +125 dBm and takes 20-30 beacons to converge on the real signal.

Best guess explanation: these are zero and the two limits of the signed 8-bit field (-128 and +127), so they look like initial values and not measurements. The FW is closed, so this is not confirmed.

wpa_supplicant's bgscan picks its scan interval from one signal_poll right after connecting, so a wrong first reading selects the wrong interval.

A reading that is too high on a link below the bgscan threshold selects the long interval. The FW RSSI trigger corrects this after ~8-35 beacons (121 of 121 reconnects). A reading that is too low on a link above the threshold selects the short interval, and nothing corrects it until bgscan's own back-off (seen in 4 of 80 reconnects that scan before connecting). For example, with bgscan="simple:5:-60:500" on a -50 dBm link, a first reading of -128 dBm gives a 5 s interval instead of 500 s.

Patch 2 ignores the FW average for 30 beacon intervals after association, so mac80211 falls back to the last RX signal. Patch 1 is a prerequisite: some frames carry no RSSI level and are reported as -128 dBm, which the fallback would expose.

Tested on WL1807MOD, FW 8.9.1.0.2 (two units, two APs, 100 and 300 TU), polling the signal every ~120 ms after association. "Junk" means more than 5 dB off the settled value:

stock: junk in 35 of 35 reconnects
both patches: junk in 0 of 20 (10 at 100 TU, 10 at 300 TU)

Testing was on 5.15 with the patches backported; on wireless-next they are build-tested only. Raw data and scripts are available on request. We are rolling this out to a few hundred devices with the same module and firmware, and I'll report back if anything turns up.

Patch 1 sets RX_FLAG_NO_SIGNAL_VAL without checking the frame type, while its kerneldoc says the flag is valid only for data frames. In testing, only QoS data frames arrived without an RSSI level, so in practice it is only set on data frames. I can add an explicit data frame check if you prefer.

I used an AI assistant (Claude) extensively: to read the driver and mac80211 code, write the test scripts, and draft the patches and messages. I have reviewed every line and can answer for it.

Changes since v1:
- Corrected the bgscan motivation in this letter and in the commit message of patch 2. v1 said a wrong first reading lasts for the whole connection; further testing showed the FW RSSI trigger corrects the too-high case. No code change.

v1: https://lore.kernel.org/linux-wireless/[email protected]/

Leav Oz-Ari (2):
wifi: wlcore: don't report -128 dBm for frames without RSSI
wifi: wlcore: don't report the FW RSSI average right after association

 drivers/net/wireless/ti/wlcore/main.c     | 14 ++++++++++++++
 drivers/net/wireless/ti/wlcore/rx.c       |  4 ++++
 drivers/net/wireless/ti/wlcore/wlcore_i.h |  3 +++
 3 files changed, 21 insertions(+)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/2 wifi: wlcore: don't report -128 dBm for frames without RSSI

Some RX descriptors from the FW have an RSSI level of 0. wl1271_rx_status() always sets the sign bit, so these frames are reported as -128 dBm and end up in the station's last signal, its signal average, and BSS entries built from received frames. Before the commit below they were reported as 0 dBm.

Set RX_FLAG_NO_SIGNAL_VAL for them instead.

Found while testing the following commit, which makes mac80211 report the last RX signal right after association: on WL1807MOD (FW 8.9.1.0.2), signal_poll returned -128 in 10 of 14 reconnects without this patch, and in none with it.

An AI assistant (Claude) helped analyse the code and draft this patch.

Fixes 5d6af28a2d24 ("wlcore: add antenna diversity reading")
---
 drivers/net/wireless/ti/wlcore/rx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/wireless/ti/wlcore/rx.c +4 -0
index 4d6f5a047..95c7c00b5 100644
@@ -69,6 +69,10 @@ static void wl1271_rx_status(struct wl1271 *wl,
 	status->signal = ((desc->rssi & RSSI_LEVEL_BITMASK) | BIT(7));
 	status->antenna = ((desc->rssi & ANT_DIVERSITY_BITMASK) >> 7);
 
+	/* some frames carry no RSSI; don't report them as -128 dBm */
+	if (!(desc->rssi & RSSI_LEVEL_BITMASK))
+		status->flag |= RX_FLAG_NO_SIGNAL_VAL;
+
 	/*
 	 * FIXME: In wl1251, the SNR should be divided by two.  In wl1271 we
 	 * need to divide by two for now, but TI has been discussing about
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 2/2 wifi: wlcore: don't report the FW RSSI average right after association

In reply to Leav Oz-Ari

For several seconds after association, the station signal reported by wlcore is wrong, often far above 0 dBm. signal_poll every ~120 ms on a WL1807MOD, 100 TU beacon interval, real signal -36 dBm (the first reading is left over from the previous connection):

    after assoc   signal      after assoc   signal
       0.03 s     -37 dBm        1.26 s     -20 dBm
       0.15 s     -89 dBm        1.38 s     -24 dBm
       0.27 s     125 dBm        1.50 s     -26 dBm
       0.40 s      92 dBm        1.63 s     -28 dBm
       0.52 s      44 dBm        1.75 s     -32 dBm
       0.64 s      27 dBm        1.87 s     -33 dBm
       0.77 s      13 dBm        2.00 s     -34 dBm
       0.89 s       2 dBm        2.12 s     -35 dBm
       1.01 s      -5 dBm        2.24 s     -35 dBm
       1.13 s     -16 dBm        2.37 s     -36 dBm

This happens on every reconnect; the first reading can also be 0 dBm, or -100 dBm and below.

The signal comes from the FW beacon RSSI average (ACX_ROAMING_STATISTICS_TBL), which restarts from about +125 dBm after association and moves 20% per beacon (avg_weight_rssi_beacon = 20). It was within 3 dB after 15-21 beacons, and within 1 dB after 18-26 at 300 TU, so the time scales with the beacon interval: about 2 s at 100 TU, 6 s at 300 TU.

Best guess explanation: these are zero and the two limits of the signed 8-bit field (-128 and +127), so they look like initial values and not measurements. The FW is closed, so this is not confirmed.

wpa_supplicant's bgscan picks its scan interval from a single signal_poll right after connecting, so a wrong first reading selects the wrong interval. With the stock driver the first poll was wrong in 13 of 35 reconnects.

A reading that is too high on a link below the bgscan threshold selects the long interval. This is corrected when the FW average falls through the threshold and the FW sends its RSSI trigger: in 121 of 121 such reconnects bgscan switched to the short interval after ~8-35 beacons.

A reading that is too low on a link above the threshold selects the short interval, and nothing corrects it: the FW average starts high and never crosses the threshold, so no trigger is sent. bgscan keeps scanning at the short interval until its own back-off, after long/short + 1 scans. This was seen in 4 of 80 reconnects that scan before connecting.

Leave the signal unset for 30 beacon intervals after association, so mac80211 reports the last RX signal instead. The FW filters beacons, so the driver can't count them and uses beacon intervals instead. 30 covers a weak -90 dBm link (about 26 beacons to within 1 dB) plus a few missed beacons.

With both patches, no reading was more than 5 dB off in 20 of 20 reconnects at 100 and 300 TU.

Tested on WL1807MOD (wl18xx, PG 2.2), FW 8.9.1.0.2, on 5.15 with the patches backported; build-tested on wireless-next. wl12xx shares this code but was not tested.

An AI assistant (Claude) helped analyse the code and draft this patch.

Fixes 0a9ffac09f77 ("wlcore: report rssi from roaming statistics")

---
v2: corrected the bgscan motivation in the commit message. No code change.

 drivers/net/wireless/ti/wlcore/main.c     | 14 ++++++++++++++
 drivers/net/wireless/ti/wlcore/wlcore_i.h |  3 +++
 2 files changed, 17 insertions(+)
drivers/net/wireless/ti/wlcore/main.c +14 -0
index 26aabf4ea..87396ba31 100644
@@ -31,6 +31,8 @@
 
 #define WL1271_BOOT_RETRIES 3
 #define WL1271_WAKEUP_TIMEOUT 500
+/* FW beacon RSSI average: ~26 beacons to settle from its post-join garbage */
+#define WLCORE_RSSI_SETTLE_BEACONS 30
 
 static const u32 cipher_suites[] = {
 	WLAN_CIPHER_SUITE_WEP40,
@@ -69,6 +71,9 @@ static int wl12xx_set_authorized(struct wl1271 *wl, struct wl12xx_vif *wlvif)
 	if (ret < 0)
 		return ret;
 
+	wlvif->sta.fw_rssi_valid_at = jiffies +
+		usecs_to_jiffies(WLCORE_RSSI_SETTLE_BEACONS *
+				 ieee80211_tu_to_usec(wlvif->beacon_int));
 	wl1271_info("Association completed.");
 	return 0;
 }
@@ -5809,6 +5814,15 @@ static void wlcore_op_sta_statistics(struct ieee80211_hw *hw,
 	if (unlikely(wl->state != WLCORE_STATE_ON))
 		goto out;
 
+	/*
+	 * The FW beacon RSSI average is garbage until enough beacons have
+	 * been averaged after association. Leave the signal unset so
+	 * mac80211 reports the last RX signal instead.
+	 */
+	if (wlvif->bss_type == BSS_TYPE_STA_BSS &&
+	    time_before(jiffies, wlvif->sta.fw_rssi_valid_at))
+		goto out;
+
 	ret = pm_runtime_resume_and_get(wl->dev);
 	if (ret < 0)
 		goto out_sleep;
drivers/net/wireless/ti/wlcore/wlcore_i.h +3 -0
index 5bdcb3416..6d9329e31 100644
@@ -370,6 +370,9 @@ struct wl12xx_vif {
 			bool qos;
 			/* channel type we started the STA role with */
 			enum nl80211_channel_type role_chan_type;
+
+			/* FW beacon RSSI average is valid from this time on */
+			unsigned long fw_rssi_valid_at;
 		} sta;
 		struct {
 			u8 global_hlid;
Signature · 1 line
2.53.0