Skip to contentSkip to conversation

use one common ath_is_mybeacon

PATCH In review Oleksij Rempel 2 participants 7 messages Jan 18, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover use one common ath_is_mybeacon

Looks like there is no more suggestions. It's time to resend complete patchset.

Most ATH driver use same beacon check. It is worth to place it to the main ATH lib.

Oleksij Rempel (5):
ath: add common function ath_is_mybeacon
ath9k: use ath_is_mybeacon
ath9k_htc: use ath_is_mybeacon
ath5k: use ath_is_mybeacon
carl9170: use ath_is_mybeacon

 drivers/net/wireless/ath/ath.h                | 10 +++++++-
 drivers/net/wireless/ath/ath5k/base.c         | 33 +++++++--------------------
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c |  4 +---
 drivers/net/wireless/ath/ath9k/recv.c         | 20 ++++------------
 drivers/net/wireless/ath/carl9170/rx.c        |  9 +++-----
 5 files changed, 25 insertions(+), 51 deletions(-)
Signature · 1 line
1.8.5.2
#1 lore raw

PATCH v3 1/5 ath: add common function ath_is_mybeacon

this function is used by most ath driver, so it can be moved here.

---
 drivers/net/wireless/ath/ath.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath.h +9 -1
index e0ba7cd..ab6a0c8 100644
@@ -17,6 +17,7 @@
 #ifndef ATH_H
 #define ATH_H
 
+#include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/if_ether.h>
 #include <linux/spinlock.h>
@@ -162,10 +163,17 @@ struct ath_common {
 	bool bt_ant_diversity;
 };
 
+static inline bool ath_is_mybeacon(struct ath_common *common,
+				   struct ieee80211_hdr *hdr)
+{
+	return ieee80211_is_beacon(hdr->frame_control) &&
+		!is_zero_ether_addr(common->curbssid) &&
+		ether_addr_equal_64bits(hdr->addr3, common->curbssid);
+}
+
 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
 				u32 len,
 				gfp_t gfp_mask);
-
 void ath_hw_setbssidmask(struct ath_common *common);
 void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key);
 int ath_key_config(struct ath_common *common,
Signature · 1 line
1.8.5.2
#2 lore raw

PATCH 2/5 ath9k: use ath_is_mybeacon

In reply to Oleksij Rempel

This patch will also change behavior of rx_beacons statistic. Instead of collecting all received beacons, it will collect only ours. This, IMO make more sense, since for troubleshooting we will need to know count of our beacons, or both.

---
 drivers/net/wireless/ath/ath9k/recv.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath9k/recv.c +4 -16
index 5bf3243..a0ebdd0 100644
@@ -969,21 +969,6 @@ static void ath9k_process_tsf(struct ath_rx_status *rs,
 		rxs->mactime += 0x100000000ULL;
 }
 
-static bool ath9k_is_mybeacon(struct ath_softc *sc, struct ieee80211_hdr *hdr)
-{
-	struct ath_hw *ah = sc->sc_ah;
-	struct ath_common *common = ath9k_hw_common(ah);
-
-	if (ieee80211_is_beacon(hdr->frame_control)) {
-		RX_STAT_INC(rx_beacons);
-		if (!is_zero_ether_addr(common->curbssid) &&
-		    ether_addr_equal_64bits(hdr->addr3, common->curbssid))
-			return true;
-	}
-
-	return false;
-}
-
 /*
  * For Decrypt or Demic errors, we only mark packet status here and always push
  * up the frame up to let mac80211 handle the actual error case, be it no
@@ -1071,7 +1056,10 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
 		goto exit;
 	}
 
-	rx_stats->is_mybeacon = ath9k_is_mybeacon(sc, hdr);
+	if (ath_is_mybeacon(common, hdr)) {
+		RX_STAT_INC(rx_beacons);
+		rx_stats->is_mybeacon = true;
+	}
 
 	/*
 	 * This shouldn't happen, but have a safety check anyway.
Signature · 1 line
1.8.5.2
#3 lore raw

PATCH 3/5 ath9k_htc: use ath_is_mybeacon

In reply to Oleksij Rempel
---
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +1 -3
index b41e008..12e0f32 100644
@@ -1075,9 +1075,7 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
 
 	last_rssi = priv->rx.last_rssi;
 
-	if (ieee80211_is_beacon(hdr->frame_control) &&
-	    !is_zero_ether_addr(common->curbssid) &&
-	    ether_addr_equal_64bits(hdr->addr3, common->curbssid)) {
+	if (ath_is_mybeacon(common, hdr)) {
 		s8 rssi = rxbuf->rxstatus.rs_rssi;
 
 		if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
Signature · 1 line
1.8.5.2
#4 lore raw

PATCH 4/5 ath5k: use ath_is_mybeacon

In reply to Oleksij Rempel
---
 drivers/net/wireless/ath/ath5k/base.c | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)
drivers/net/wireless/ath/ath5k/base.c +8 -25
index d85c312..ef35da8 100644
@@ -1238,14 +1238,11 @@ static void
 ath5k_check_ibss_tsf(struct ath5k_hw *ah, struct sk_buff *skb,
 		     struct ieee80211_rx_status *rxs)
 {
-	struct ath_common *common = ath5k_hw_common(ah);
 	u64 tsf, bc_tstamp;
 	u32 hw_tu;
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
 
-	if (ieee80211_is_beacon(mgmt->frame_control) &&
-	    le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS &&
-	    ether_addr_equal_64bits(mgmt->bssid, common->curbssid)) {
+	if (le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS) {
 		/*
 		 * Received an IBSS beacon with the same BSSID. Hardware *must*
 		 * have updated the local TSF. We have to work around various
@@ -1301,23 +1298,6 @@ ath5k_check_ibss_tsf(struct ath5k_hw *ah, struct sk_buff *skb,
 	}
 }
 
-static void
-ath5k_update_beacon_rssi(struct ath5k_hw *ah, struct sk_buff *skb, int rssi)
-{
-	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
-	struct ath_common *common = ath5k_hw_common(ah);
-
-	/* only beacons from our BSSID */
-	if (!ieee80211_is_beacon(mgmt->frame_control) ||
-	    !ether_addr_equal_64bits(mgmt->bssid, common->curbssid))
-		return;
-
-	ewma_add(&ah->ah_beacon_rssi_avg, rssi);
-
-	/* in IBSS mode we should keep RSSI statistics per neighbour */
-	/* le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS */
-}
-
 /*
  * Compute padding position. skb must contain an IEEE 802.11 frame
  */
@@ -1390,6 +1370,7 @@ ath5k_receive_frame(struct ath5k_hw *ah, struct sk_buff *skb,
 		    struct ath5k_rx_status *rs)
 {
 	struct ieee80211_rx_status *rxs;
+	struct ath_common *common = ath5k_hw_common(ah);
 
 	ath5k_remove_padding(skb);
 
@@ -1442,11 +1423,13 @@ ath5k_receive_frame(struct ath5k_hw *ah, struct sk_buff *skb,
 
 	trace_ath5k_rx(ah, skb);
 
-	ath5k_update_beacon_rssi(ah, skb, rs->rs_rssi);
+	if (ath_is_mybeacon(common, (struct ieee80211_hdr *)skb->data)) {
+		ewma_add(&ah->ah_beacon_rssi_avg, rs->rs_rssi);
 
-	/* check beacons in IBSS mode */
-	if (ah->opmode == NL80211_IFTYPE_ADHOC)
-		ath5k_check_ibss_tsf(ah, skb, rxs);
+		/* check beacons in IBSS mode */
+		if (ah->opmode == NL80211_IFTYPE_ADHOC)
+			ath5k_check_ibss_tsf(ah, skb, rxs);
+	}
 
 	ieee80211_rx(ah->hw, skb);
 }
Signature · 1 line
1.8.5.2
#5 lore raw

PATCH 5/5 carl9170: use ath_is_mybeacon

In reply to Oleksij Rempel
---
 drivers/net/wireless/ath/carl9170/rx.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/carl9170/rx.c +3 -6
index 1b1b207..536bc46a 100644
@@ -519,6 +519,7 @@ static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len)
 {
 	struct ieee80211_hdr *hdr = data;
 	struct ieee80211_tim_ie *tim_ie;
+	struct ath_common *common = &ar->common;
 	u8 *tim;
 	u8 tim_len;
 	bool cam;
@@ -526,17 +527,13 @@ static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len)
 	if (likely(!(ar->hw->conf.flags & IEEE80211_CONF_PS)))
 		return;
 
-	/* check if this really is a beacon */
-	if (!ieee80211_is_beacon(hdr->frame_control))
-		return;
-
 	/* min. beacon length + FCS_LEN */
 	if (len <= 40 + FCS_LEN)
 		return;
 
+	/* check if this really is a beacon */
 	/* and only beacons from the associated BSSID, please */
-	if (!ether_addr_equal_64bits(hdr->addr3, ar->common.curbssid) ||
-	    !ar->common.curaid)
+	if (!ath_is_mybeacon(common, hdr) || !common->curaid)
 		return;
 
 	ar->ps.last_beacon = jiffies;
Signature · 1 line
1.8.5.2
#6 lore raw
In reply to Oleksij Rempel
Quoted 5 lines · Oleksij Rempel

Looks like there is no more suggestions. It's time to resend complete patchset.

Most ATH driver use same beacon check. It is worth to place it to the main ATH lib.

This has already been merged in wireless-testing...

Sujith