linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Senthil Balasubramanian <senthilkumar@atheros.com>
To: <linville@tuxdriver.com>
Cc: <Jouni.Malinen@Atheros.com>, <Luis.Rodriguez@Atheros.com>,
	<linux-wireless@vger.kernel.org>,
	Senthil Balasubramanian <senthilkumar@atheros.com>
Subject: [PATCH 2/2] ath9k: Fix bogus RSSI report from Hardware during RX.
Date: Wed, 17 Jun 2009 09:57:08 +0530	[thread overview]
Message-ID: <1245212828-7342-3-git-send-email-senthilkumar@atheros.com> (raw)
In-Reply-To: <1245212828-7342-2-git-send-email-senthilkumar@atheros.com>

The hardware may report errorneous RSSI in some cases. Detect it and
don't use them for reporting the signal strength to the stack.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
---
 drivers/net/wireless/ath/ath9k/ath9k.h |    5 +++--
 drivers/net/wireless/ath/ath9k/recv.c  |   21 +++++++++++++--------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 3939396..93245dd 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -300,8 +300,9 @@ struct ath_tx_control {
 #define ATH_TX_XRETRY       0x02
 #define ATH_TX_BAR          0x04
 
-#define ATH_RSSI_LPF_LEN           10
-#define RSSI_LPF_THRESHOLD         -20
+#define ATH_RSSI_LPF_LEN 		10
+#define RSSI_LPF_THRESHOLD		-20
+#define ATH9K_RSSI_BAD			0x80
 #define ATH_RSSI_EP_MULTIPLIER     (1<<7)
 #define ATH_EP_MUL(x, mul)         ((x) * (mul))
 #define ATH_RSSI_IN(x)             (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER))
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 0f62795..889d0c9 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -147,6 +147,7 @@ static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds,
 	struct ieee80211_hw *hw;
 	struct ieee80211_sta *sta;
 	struct ath_node *an;
+	int last_rssi = ATH_RSSI_DUMMY_MARKER;
 
 
 	hdr = (struct ieee80211_hdr *)skb->data;
@@ -236,17 +237,21 @@ static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds,
 	sta = ieee80211_find_sta(sc->hw, hdr->addr2);
 	if (sta) {
 		an = (struct ath_node *) sta->drv_priv;
-		ATH_RSSI_LPF(an->last_rssi, ds->ds_rxstat.rs_rssi);
-		if (likely(an->last_rssi != ATH_RSSI_DUMMY_MARKER))
-			ds->ds_rxstat.rs_rssi = ATH_EP_RND(an->last_rssi,
-					ATH_RSSI_EP_MULTIPLIER);
-		if (ds->ds_rxstat.rs_rssi < 0)
-			ds->ds_rxstat.rs_rssi = 0;
-		else if (ds->ds_rxstat.rs_rssi > 127)
-			ds->ds_rxstat.rs_rssi = 127;
+		if (ds->ds_rxstat.rs_rssi != ATH9K_RSSI_BAD &&
+		   !ds->ds_rxstat.rs_moreaggr)
+			ATH_RSSI_LPF(an->last_rssi, ds->ds_rxstat.rs_rssi);
+		last_rssi = an->last_rssi;
 	}
 	rcu_read_unlock();
 
+	if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
+		ds->ds_rxstat.rs_rssi = ATH_EP_RND(last_rssi,
+					ATH_RSSI_EP_MULTIPLIER);
+	if (ds->ds_rxstat.rs_rssi < 0)
+		ds->ds_rxstat.rs_rssi = 0;
+	else if (ds->ds_rxstat.rs_rssi > 127)
+		ds->ds_rxstat.rs_rssi = 127;
+
 	rx_status->mactime = ath_extend_tsf(sc, ds->ds_rxstat.rs_tstamp);
 	rx_status->band = hw->conf.channel->band;
 	rx_status->freq = hw->conf.channel->center_freq;
-- 
1.6.0.4


  reply	other threads:[~2009-06-17  4:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17  4:27 ATH9K Bug fixes Senthil Balasubramanian
2009-06-17  4:27 ` [PATCH 1/1] ath9k: Handle different TX and RX streams properly Senthil Balasubramanian
2009-06-17  4:27   ` Senthil Balasubramanian [this message]
2009-06-17 19:00 ` ATH9K Bug fixes John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245212828-7342-3-git-send-email-senthilkumar@atheros.com \
    --to=senthilkumar@atheros.com \
    --cc=Jouni.Malinen@Atheros.com \
    --cc=Luis.Rodriguez@Atheros.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).