Skip to contentSkip to conversation

ath9k_htc: update RSSI values only when the device is associated

PATCH New Bernhard Urban 2 participants 2 messages Feb 1, 2013 – Feb 5, 2013 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k_htc: update RSSI values only when the device is associated

add an if-guard, otherwise iw(8) reports weird signal strengths.

The behaviour was fine before this commit:

	7c277349ecbd66e19fad3d949fa6ef6c131a3b62

Therefore, this patch is a partially revert of it.

In my testsetup, I have two access points:
00:12:XX within one meter physically range
c0:c1:XX ~15m, two (thin) walls

	w/o patch:
	  00:12:XX  -82.00 dBm
	  c0:c1:XX  -84.00 dBm

	with patch:
	  00:12:XX  -45.00 dBm
	  c0:c1:XX  -63.00 dBm

Tested with "TP-Link TL-WN722N"

---
 drivers/net/wireless/ath/ath9k/htc.h          |    1 +
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c |   29 +++++++++++++++----------
 2 files changed, 19 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath9k/htc.h +1 -0
index b30596f..602e19b 100644
@@ -22,6 +22,7 @@
 #include <linux/firmware.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/etherdevice.h>
 #include <linux/leds.h>
 #include <linux/slab.h>
 #include <net/mac80211.h>
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +18 -11
index 06cdcb7..a38435a 100644
@@ -969,6 +969,7 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
 	int hdrlen, padpos, padsize;
 	int last_rssi = ATH_RSSI_DUMMY_MARKER;
 	__le16 fc;
+	u8 is_mybeacon;
 
 	if (skb->len < HTC_RX_FRAME_HEADER_SIZE) {
 		ath_err(common, "Corrupted RX frame, dropping (len: %d)\n",
@@ -1060,22 +1061,28 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
 	ath9k_process_rate(hw, rx_status, rxbuf->rxstatus.rs_rate,
 			   rxbuf->rxstatus.rs_flags);
 
-	if (rxbuf->rxstatus.rs_rssi != ATH9K_RSSI_BAD &&
-	    !rxbuf->rxstatus.rs_moreaggr)
-		ATH_RSSI_LPF(priv->rx.last_rssi,
-			     rxbuf->rxstatus.rs_rssi);
+	is_mybeacon = ieee80211_is_beacon(fc) &&
+				  !is_zero_ether_addr(common->curbssid) &&
+				  ether_addr_equal(hdr->addr3, common->curbssid);
 
-	last_rssi = priv->rx.last_rssi;
+	if (is_mybeacon && priv->ah->opmode == NL80211_IFTYPE_STATION) {
+		if (rxbuf->rxstatus.rs_rssi != ATH9K_RSSI_BAD &&
+		    !rxbuf->rxstatus.rs_moreaggr)
+			ATH_RSSI_LPF(priv->rx.last_rssi,
+				     rxbuf->rxstatus.rs_rssi);
 
-	if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
-		rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
-						     ATH_RSSI_EP_MULTIPLIER);
+		last_rssi = priv->rx.last_rssi;
 
-	if (rxbuf->rxstatus.rs_rssi < 0)
-		rxbuf->rxstatus.rs_rssi = 0;
+		if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) {
+			s8 rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
+			rxbuf->rxstatus.rs_rssi = rssi;
+		}
+
+		if (rxbuf->rxstatus.rs_rssi < 0)
+			rxbuf->rxstatus.rs_rssi = 0;
 
-	if (ieee80211_is_beacon(fc))
 		priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
+	}
 
 	rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
 	rx_status->band = hw->conf.channel->band;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 ath9k_htc: update RSSI values only when the device is associated

Quoted 5 lines · Bernhard Urban

add an if-guard, otherwise iw(8) reports weird signal strengths.

The behaviour was fine before this commit:

	7c277349ecbd66e19fad3d949fa6ef6c131a3b62

Therefore, this patch is a partially revert of it.

I think your commit message is a bit misleading. The main problem with signal strength reporting is not that it's missing some checks for if the device is associated, or if the received frame is a local beacon.

The main problem is in these lines below:

drivers/net/wireless/ath/ath9k/htc_drv_txrx.c static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv, · line 1079

Quoted 4 lines
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +4 -0
+		if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) {
+			s8 rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
+			rxbuf->rxstatus.rs_rssi = rssi;
+		}

It does not make any sense to update the per-frame RSSI value with any sort of average. ath9k filters out invalid RSSI values by ignoring rssi for ANI when rx_stats->rs_moreaggr is set. In that case it also sets the RX_FLAG_NO_SIGNAL_VAL flag to tell mac80211 to ignore the value for its own signal strength averages.

- Felix