Re: [PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param

2015-12-17 Thread Janusz Dziedzic
On 11 December 2015 at 09:19, Kalle Valo  wrote:
> Janusz Dziedzic  writes:
>
>> 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 
>
> Why? What's the use case?
>
By default beacon_int/2 is used in current implementation.
This patch was developed as a proof of concept in case we would like
to use MCC and need change this 50/50.
Eg, for some reason we need higher BW/ more air time for STA or AP -
depends on case.
For my case STA connection to Gateway was more important that clients
connected to an AP - so just used
70/30.

> And isn't there a better way to do this? Like using nl80211 (via
> wpasupplicant?) or debugfs?
>
I wasn't sure here, but maybe some prio param on the VIF could be used here?
Eg.
VIF1 - prio 50
VIF2 - prio 100

VIF1_time = 50 / (50 + 100) = 33%
VIF2_time = 100 / (50 + 100) = 66%

with some default prio eg. 100.
But for sure this is more work, and I am not sure someone else will need this?

BR
Janusz
> --
> Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param

2015-12-11 Thread Kalle Valo
Janusz Dziedzic  writes:

> 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 

Why? What's the use case?

And isn't there a better way to do this? Like using nl80211 (via
wpasupplicant?) or debugfs?

-- 
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 11/13] ath9k: MCC add sta_ap_ratio module param

2015-11-27 Thread Janusz Dziedzic
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 
---
 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;