From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
To: linux-wireless@vger.kernel.org
Cc: ath9k-devel@lists.ath9k.org, nbd@openwrt.org,
Janusz Dziedzic <janusz.dziedzic@tieto.com>
Subject: [PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param
Date: Fri, 27 Nov 2015 09:37:16 +0100 [thread overview]
Message-ID: <1448613438-5173-11-git-send-email-janusz.dziedzic@tieto.com> (raw)
In-Reply-To: <1448613438-5173-1-git-send-email-janusz.dziedzic@tieto.com>
In case of MCC we can setup STA/AP(GO) ratio.
Eg. setting sta_ap_ratio=80
STA will get 80% of time, while AP(GO) 20%.
Setup correct ctwindow.
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
drivers/net/wireless/ath/ath9k/ath9k.h | 2 +
drivers/net/wireless/ath/ath9k/channel.c | 69 +++++++++++++++++++++-----------
drivers/net/wireless/ath/ath9k/hw.h | 1 +
drivers/net/wireless/ath/ath9k/init.c | 3 ++
4 files changed, 51 insertions(+), 24 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index b42f4a9..4616229 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -37,6 +37,7 @@ extern int ath9k_modparam_nohwcrypt;
extern int ath9k_led_blink;
extern bool is_ath9k_unloaded;
extern int ath9k_use_chanctx;
+extern int ath9k_sta_ap_ratio;
/*************************/
/* Descriptor Management */
@@ -335,6 +336,7 @@ struct ath_chanctx {
struct timespec tsf_ts;
u64 tsf_val;
u32 last_beacon;
+ u32 ctwindow;
int flush_timeout;
u16 txpower;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index c94d7d9..8ab856c 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -313,11 +313,21 @@ ath_chanctx_get_next(struct ath_softc *sc, struct ath_chanctx *ctx)
return &sc->chanctx[!idx];
}
+static u32 get_ratio(u32 beacon_int)
+{
+ if (ath9k_sta_ap_ratio < 20 ||
+ ath9k_sta_ap_ratio > 80)
+ return beacon_int / 2;
+
+ return (beacon_int * ath9k_sta_ap_ratio) / 100;
+}
+
static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_chanctx *prev, *cur;
struct timespec ts;
- u32 cur_tsf, prev_tsf, beacon_int;
+ u32 cur_tsf, prev_tsf, beacon_int, diff;
s32 offset;
beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
@@ -344,7 +354,14 @@ static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
if (offset < 0 || offset > 3 * beacon_int)
return;
- offset = beacon_int / 2 - (offset % beacon_int);
+ diff = 2 * prev->ctwindow;
+ diff += sc->sched.channel_switch_time;
+ if (diff > beacon_int / 2)
+ diff = beacon_int / 2;
+
+ ath_dbg(common, CHAN_CTX, "Setup beacon interval offset %u ms\n",
+ diff / 1000);
+ offset = diff - (offset % beacon_int);
prev->tsf_val += offset;
}
@@ -435,7 +452,7 @@ static void ath_chanctx_set_periodic_noa(struct ath_softc *sc,
sc->sched.channel_switch_time;
else
avp->noa_duration =
- TU_TO_USEC(cur_conf->beacon_interval) / 2 +
+ TU_TO_USEC(get_ratio(cur_conf->beacon_interval)) +
sc->sched.channel_switch_time;
if (test_bit(ATH_OP_SCANNING, &common->op_flags) ||
@@ -481,7 +498,8 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
struct ath_beacon_config *cur_conf;
struct ath_vif *avp = NULL;
struct ath_chanctx *ctx;
- u32 tsf_time;
+ u32 tsf_time, defer_time;
+ u32 beacon_resp_time = ah->config.sw_beacon_response_time;
u32 beacon_int;
if (vif)
@@ -565,10 +583,26 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
cur_conf = &sc->cur_chan->beacon;
beacon_int = TU_TO_USEC(cur_conf->beacon_interval);
- /* defer channel switch by a quarter beacon interval */
- tsf_time = sc->sched.next_tbtt + beacon_int / 4;
+ /* defer channel switch */
+ defer_time = beacon_int - get_ratio(beacon_int);
+ defer_time -= sc->sched.channel_switch_time;
+ defer_time /= 2;
+
+ if (defer_time < TU_TO_USEC(2 + beacon_resp_time)) {
+ defer_time *= 2;
+ if (defer_time > TU_TO_USEC(3 + beacon_resp_time))
+ defer_time -= TU_TO_USEC(3 + beacon_resp_time);
+ else
+ defer_time = 1000;
+ }
+
+ ath_dbg(common, CHAN_CTX, "Setup defer_time %u (%u ms)\n",
+ defer_time, defer_time / 1000);
+
+ tsf_time = sc->sched.next_tbtt + defer_time;
sc->sched.switch_start_time = tsf_time;
sc->cur_chan->last_beacon = sc->sched.next_tbtt;
+ sc->cur_chan->ctwindow = defer_time;
/*
* If an offchannel switch is scheduled to happen after
@@ -707,7 +741,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER;
sc->sched.wait_switch = false;
- tsf_time = TU_TO_USEC(cur_conf->beacon_interval) / 2;
+ tsf_time = TU_TO_USEC(get_ratio(cur_conf->beacon_interval));
if (sc->sched.extend_absence) {
sc->sched.beacon_miss = 0;
@@ -1454,26 +1488,13 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
static u8 ath9k_get_ctwin(struct ath_softc *sc, struct ath_vif *avp)
{
- struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon;
- u8 switch_time, ctwin;
-
/*
* Channel switch in multi-channel mode is deferred
- * by a quarter beacon interval when handling
- * ATH_CHANCTX_EVENT_BEACON_PREPARE, so the P2P-GO
- * interface is guaranteed to be discoverable
- * for that duration after a TBTT.
+ * when handling ATH_CHANCTX_EVENT_BEACON_PREPARE,
+ * so the P2P-GO interface is guaranteed to be
+ * discoverable for that duration after a TBTT.
*/
- switch_time = cur_conf->beacon_interval / 4;
-
- ctwin = avp->vif->bss_conf.p2p_noa_attr.oppps_ctwindow;
- if (ctwin && (ctwin < switch_time))
- return ctwin;
-
- if (switch_time < P2P_DEFAULT_CTWIN)
- return 0;
-
- return P2P_DEFAULT_CTWIN;
+ return USEC_TO_TU(sc->cur_chan->ctwindow);
}
void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp,
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 4f0a3f6..7528f00 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -193,6 +193,7 @@
#define INIT_BCON_CNTRL_REG 0x00000000
#define TU_TO_USEC(_tu) ((_tu) << 10)
+#define USEC_TO_TU(_us) ((_us) >> 10)
#define ATH9K_HW_RX_HP_QDEPTH 16
#define ATH9K_HW_RX_LP_QDEPTH 128
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 2e2b92b..6729a5f 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -67,6 +67,9 @@ int ath9k_use_chanctx;
module_param_named(use_chanctx, ath9k_use_chanctx, int, 0444);
MODULE_PARM_DESC(use_chanctx, "Enable channel context for concurrency");
+int ath9k_sta_ap_ratio;
+module_param_named(sta_ap_ratio, ath9k_sta_ap_ratio, int, 0444);
+MODULE_PARM_DESC(sta_ap_ratio, "sta/ap ratio 20-80");
#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */
bool is_ath9k_unloaded;
--
1.9.1
next prev parent reply other threads:[~2015-11-27 8:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 8:37 [PATCH v2 01/13] ath9k: add debug messages to aggr/chanctx funcs Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 02/13] ath9k: print real timer value Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 03/13] ath9k: queue null frames in case of MCC Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 04/13] ath9k: P2P_CLIENT, send frames after 1ms AP/GO will aprear Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 05/13] ath9k: use u32 when calculate tsf Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 06/13] ath9k: setup correct skb priority for nullfunc Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 07/13] ath9k: MCC enable Opportunistic Power Save Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 08/13] ath9k: P2P_CLIENT, get/set NOA correctly Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 09/13] ath9k: request NOA update when chanctx active Janusz Dziedzic
2015-12-01 13:13 ` Kalle Valo
2016-01-28 8:21 ` Kalle Valo
2015-11-27 8:37 ` [PATCH v2 10/13] ath9k: MCC, add NOA also in case of an AP Janusz Dziedzic
2015-11-27 8:37 ` Janusz Dziedzic [this message]
2015-12-11 8:19 ` [PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param Kalle Valo
2015-12-17 9:44 ` Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 12/13] ath9k: MCC, print time elapsed between events Janusz Dziedzic
2015-11-27 8:37 ` [PATCH v2 13/13] ath9k: remove ath9k_mod_tsf64_tu Janusz Dziedzic
2015-12-08 15:03 ` [PATCH v2 01/13] ath9k: add debug messages to aggr/chanctx funcs Kalle Valo
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=1448613438-5173-11-git-send-email-janusz.dziedzic@tieto.com \
--to=janusz.dziedzic@tieto.com \
--cc=ath9k-devel@lists.ath9k.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@openwrt.org \
/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).