linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivo van Doorn <ivdoorn@gmail.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, rt2400-devel@lists.sourceforge.net
Subject: [PATCH] rt2x00: Only update rssi average approximation on receiving beacon frames.
Date: Tue, 27 Nov 2007 21:50:26 +0100	[thread overview]
Message-ID: <200711272150.26860.IvDoorn@gmail.com> (raw)
In-Reply-To: <200711272146.53518.IvDoorn@gmail.com>

From: Mattias Nissler <mattias.nissler@gmx.de>

Restrict rssi average updating to beacon frames of the bssid the
interface is
associated with. Without this restriction, strong signals belonging to other
BSS, e.g. beacon frames coming from a nearby AP, would cause incorrectly high
rssi approximation values. This would then cause the link tuner to reduce
sensitivity, resulting in transmissions from the BSS associated to to be
missed.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
---
 drivers/net/wireless/rt2x00/rt2x00.h    |    7 +++++++
 drivers/net/wireless/rt2x00/rt2x00dev.c |   19 ++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 103a122..218068b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -32,6 +32,7 @@
 #include <linux/workqueue.h>
 #include <linux/firmware.h>
 #include <linux/mutex.h>
+#include <linux/etherdevice.h>
 
 #include <net/mac80211.h>
 
@@ -149,6 +150,12 @@ static inline int is_probe_resp(u16 fc)
 		((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP));
 }
 
+static inline int is_beacon(u16 fc)
+{
+	return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
+		((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON));
+}
+
 /*
  * Chipset identification
  * The chipset on the device is composed of a RT and RF chip.
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index bd7b738..a771a09 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -526,11 +526,14 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
 		      struct rxdata_entry_desc *desc)
 {
 	struct rt2x00_dev *rt2x00dev = entry->ring->rt2x00dev;
+	struct interface *intf = &rt2x00dev->interface;
 	struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
 	struct ieee80211_hw_mode *mode;
 	struct ieee80211_rate *rate;
+	struct ieee80211_hdr *hdr;
 	unsigned int i;
 	int val = 0;
+	u16 fc;
 
 	/*
 	 * Update RX statistics.
@@ -555,7 +558,21 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
 		}
 	}
 
-	rt2x00lib_update_link_stats(&rt2x00dev->link, desc->rssi);
+	/*
+	 * Only update link status if this is a beacon frame carrying our
+	 * bssid.
+	 */
+	hdr = (struct ieee80211_hdr *) skb->data;
+	if (skb->len >= sizeof(struct ieee80211_hdr *)) {
+		fc = le16_to_cpu(hdr->frame_control);
+		if ((intf->type == IEEE80211_IF_TYPE_STA
+		     || intf->type == IEEE80211_IF_TYPE_IBSS)
+		    && is_beacon(fc)
+		    && compare_ether_addr(hdr->addr3, intf->bssid) == 0)
+			rt2x00lib_update_link_stats(&rt2x00dev->link,
+						    desc->rssi);
+	}
+
 	rt2x00dev->link.qual.rx_success++;
 
 	rx_status->rate = val;
-- 
1.5.3.6


  parent reply	other threads:[~2007-11-27 19:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 20:46 Please pull 'upstream' branch of rt2x00 Ivo van Doorn
2007-11-27 20:47 ` [PATCH 01/11] rt2x00: Replace DRV_NAME with KBUILD_MODNAME Ivo van Doorn
2007-11-27 20:47 ` [PATCH 02/11] rt2x00: Extend PLCP descriptor definition for rt2400pci Ivo van Doorn
2007-11-27 20:48 ` [PATCH 03/11] rt2x00: Move register value/offset files into new folder Ivo van Doorn
2007-11-27 20:48 ` [PATCH 04/11] rt2x00: Add chipset version to chipset debugfs entry Ivo van Doorn
2007-11-27 20:49 ` [PATCH 05/11] rt2x00: Add skb descriptor Ivo van Doorn
2007-11-27 20:49 ` [PATCH 06/11] rt2x00: Add TX/RX frame dumping facility Ivo van Doorn
2007-11-27 22:21   ` [Rt2400-devel] " Mattias Nissler
2007-11-28 20:18     ` Ivo van Doorn
2007-11-27 20:49 ` [PATCH 07/11] rt2x00: Use IEEE80211_IF_TYPE_INVALID directly Ivo van Doorn
2007-11-27 20:51   ` [PATCH 08/11] " Ivo van Doorn
2007-11-27 20:50 ` Ivo van Doorn [this message]
2007-11-27 20:51 ` [PATCH 09/11] rt2x00: Remove redundant code in rfkill setup Ivo van Doorn
2007-11-27 20:51 ` [PATCH 10/11] rt2x00: Cleanup rfkill Ivo van Doorn
2007-11-27 20:52 ` [PATCH 11/11] rt2x00: Release rt2x00 2.0.13 Ivo van Doorn
2007-11-27 20:54 ` Please pull 'upstream' branch of rt2x00 Ivo van Doorn
2007-11-29 22:26   ` John W. Linville
2007-11-30  9:51     ` Ivo van Doorn

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=200711272150.26860.IvDoorn@gmail.com \
    --to=ivdoorn@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=rt2400-devel@lists.sourceforge.net \
    /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).