Development issues regarding the cerowrt test router project
 help / color / mirror / Atom feed
From: Dave Taht <dave.taht@gmail.com>
To: make-wifi-fast@lists.bufferbloat.net,
	 "cerowrt-devel@lists.bufferbloat.net"
	<cerowrt-devel@lists.bufferbloat.net>
Subject: [Cerowrt-devel] Fwd: [Battlemesh] BSS load element patch
Date: Fri, 7 Aug 2015 12:08:49 +0200	[thread overview]
Message-ID: <CAA93jw4651_Xnv12B9gWD7o9G6DVAhO4iTtFKTEAK-Wdj+YmRQ@mail.gmail.com> (raw)
In-Reply-To: <55BFBBF1.4080709@lena.im>


[-- Attachment #1.1.1: Type: text/plain, Size: 1045 bytes --]

a thought
---------- Forwarded message ----------
From: Arthur LENA <arthur@lena.im>
Date: Mon, Aug 3, 2015 at 9:07 PM
Subject: [Battlemesh] BSS load element patch
To: battlemesh@ml.ninux.org


Hi all!

Attached the patch adding the BSS Load IE to the beacon sent by the ath9k
driver (specification can be found @ IEEE802.11-2012 §8.4.2.30). It fills
the channel utilization field (based on cycles counters read out of the
chipsets) and the station count field. This patch applies successfully to
the compat-wireless package in the OpenWRT build environment (trunk r45674)
and was tested on the WDR4300. All comments are welcome!!



Cheers
Arthur

_______________________________________________
Battlemesh mailing list
Battlemesh@ml.ninux.org
http://ml.ninux.org/mailman/listinfo/battlemesh




-- 
Dave Täht
worldwide bufferbloat report:
http://www.dslreports.com/speedtest/results/bufferbloat
And:
What will it take to vastly improve wifi for everyone?
https://plus.google.com/u/0/explore/makewififast

[-- Attachment #1.1.2: Type: text/html, Size: 1926 bytes --]

[-- Attachment #1.2: Type: image/png, Size: 28589 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qbss_ath9k.patch --]
[-- Type: text/x-patch; charset=US-ASCII; name="qbss_ath9k.patch", Size: 4575 bytes --]

commit 7e1e7ca17d3159b562bcc59d7bc27fabb1f50d73
Author: Arthur Léna <Lena@ftw.at>
Date:   Tue May 12 19:39:48 2015 +0200

    ath9k: add QBSS IE to the beacons
    
    Summary:
    * the QBSS IE is added to the beacons in the ath9k driver.
    * the value of the channel load element is calculated over a fixed
    	period of 50 beacon intervals (i.e., 5 seconds with the
    	default beacon interval).
    * a counter for the number of associated stations has been added
    	for each virtual interface in the ath_vif struct. This allows
    	to fill the station count element of the QBSS IE.

diff --git a/package/kernel/mac80211/patches/940-ath9k_qbss_load_element.patch b/package/kernel/mac80211/patches/940-ath9k_qbss_load_element.patch
new file mode 100644
index 0000000..393ab99
--- /dev/null
+++ b/package/kernel/mac80211/patches/940-ath9k_qbss_load_element.patch
@@ -0,0 +1,109 @@
+--- a/drivers/net/wireless/ath/ath9k/beacon.c
++++ b/drivers/net/wireless/ath/ath9k/beacon.c
+@@ -15,6 +15,7 @@
+  */
+
+ #include <linux/dma-mapping.h>
++#include <linux/kernel.h>
+ #include "ath9k.h"
+
+ #define FUDGE 2
+@@ -109,6 +110,46 @@ static void ath9k_beacon_setup(struct at
+	ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
+ }
+
++static void ath9k_beacon_add_qbss(struct ath_softc *sc,
++	struct ieee80211_vif *vif, struct sk_buff *skb, int beacon_interval)
++{
++    /* default - 802.11e annex D: dot11ChannelUtilizationBeaconInterval */
++    static const u8 qbss_ie_hdr[] = {
++        WLAN_EID_QBSS_LOAD,             /* type */
++        0x05,                           /* length */
++        0x00, 0x00, 0x00, 0x00, 0x00   /* dummy values */
++    };
++    u8 *hdr;
++    struct ath_hw *ah = sc->sc_ah;
++    struct ath_common *common = ath9k_hw_common(ah);
++	struct ath_vif *avp = (void *)vif->drv_priv;
++    static const u8 QBSS_CU_BEACON_INTERVAL_MAX = 50;
++    static u32 channel_time_busy = 0;
++    static u64 last_channel_time_busy = 0;
++    static u8 qbss_cu_beacon_int = 0;
++    static u8 qbss_channel_load;
++
++    /* get the information out of the survey struct for the current channel */
++    spin_lock_bh(&common->cc_lock);
++
++    if (++qbss_cu_beacon_int == QBSS_CU_BEACON_INTERVAL_MAX) {
++        channel_time_busy = sc->cur_survey->time_busy - last_channel_time_busy;
++        channel_time_busy += ath_update_survey_stats(sc);
++        qbss_channel_load = channel_time_busy * 255 /
++            (beacon_interval * qbss_cu_beacon_int);
++        channel_time_busy = 0;
++        qbss_cu_beacon_int = 0;
++        last_channel_time_busy = sc->cur_survey->time_busy;
++    }
++
++    spin_unlock_bh(&common->cc_lock);
++
++    hdr = skb_put(skb, sizeof(qbss_ie_hdr));
++    memcpy(hdr, qbss_ie_hdr, sizeof(qbss_ie_hdr));
++	*((u16 *) (hdr + 2)) = cpu_to_le16(avp->n_assoc_stations);
++    *(hdr+4) = qbss_channel_load;
++}
++
+ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
+					     struct ieee80211_vif *vif)
+ {
+@@ -151,6 +192,9 @@ static struct ath_buf *ath9k_beacon_gene
+	if (vif->p2p)
+		ath9k_beacon_add_noa(sc, avp, skb);
+
++    ath9k_beacon_add_qbss(sc, vif, skb,
++        avp->chanctx->beacon.beacon_interval);
++
+	bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
+					 skb->len, DMA_TO_DEVICE);
+	if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -623,6 +623,8 @@ struct ath_vif {
+	u32 noa_duration;
+	bool periodic_noa;
+	bool oneshot_noa;
++
++	u16 n_assoc_stations;
+ };
+
+ struct ath9k_vif_iter_data {
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1488,6 +1488,7 @@ static int ath9k_sta_add(struct ieee8021
+	struct ath_softc *sc = hw->priv;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	struct ath_node *an = (struct ath_node *) sta->drv_priv;
++	struct ath_vif *avp = (void *)vif->drv_priv;
+	struct ieee80211_key_conf ps_key = { };
+	int key;
+
+@@ -1503,6 +1504,8 @@ static int ath9k_sta_add(struct ieee8021
+		an->key_idx[0] = key;
+	}
+
++	avp->n_assoc_stations++;
++
+	return 0;
+ }
+
+@@ -1527,9 +1530,11 @@ static int ath9k_sta_remove(struct ieee8
+			    struct ieee80211_sta *sta)
+ {
+	struct ath_softc *sc = hw->priv;
++	struct ath_vif *avp = (void *)vif->drv_priv;
+
+	ath9k_del_ps_key(sc, vif, sta);
+	ath_node_detach(sc, sta);
++	avp->n_assoc_stations--;
+
+	return 0;
+ }

           reply	other threads:[~2015-08-07 10:08 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <55BFBBF1.4080709@lena.im>]

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

  List information: https://lists.bufferbloat.net/postorius/lists/cerowrt-devel.lists.bufferbloat.net/

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

  git send-email \
    --in-reply-to=CAA93jw4651_Xnv12B9gWD7o9G6DVAhO4iTtFKTEAK-Wdj+YmRQ@mail.gmail.com \
    --to=dave.taht@gmail.com \
    --cc=cerowrt-devel@lists.bufferbloat.net \
    --cc=make-wifi-fast@lists.bufferbloat.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