2015-11-27 08:37:25

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 01/13] ath9k: add debug messages to aggr/chanctx funcs

Add/extend debug messages when chanctx used.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 11 ++++++++---
drivers/net/wireless/ath/ath9k/hw.c | 8 ++++----
drivers/net/wireless/ath/ath9k/xmit.c | 15 +++++++++++++++
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 90f5773..35802c9 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -403,7 +403,7 @@ static void ath_chanctx_offchannel_noa(struct ath_softc *sc,
avp->offchannel_duration = sc->sched.offchannel_duration;

ath_dbg(common, CHAN_CTX,
- "offchannel noa_duration: %d, noa_start: %d, noa_index: %d\n",
+ "offchannel noa_duration: %d, noa_start: %u, noa_index: %d\n",
avp->offchannel_duration,
avp->offchannel_start,
avp->noa_index);
@@ -443,7 +443,7 @@ static void ath_chanctx_set_periodic_noa(struct ath_softc *sc,
avp->periodic_noa = true;

ath_dbg(common, CHAN_CTX,
- "noa_duration: %d, noa_start: %d, noa_index: %d, periodic: %d\n",
+ "noa_duration: %d, noa_start: %u, noa_index: %d, periodic: %d\n",
avp->noa_duration,
avp->noa_start,
avp->noa_index,
@@ -464,7 +464,7 @@ static void ath_chanctx_set_oneshot_noa(struct ath_softc *sc,
avp->noa_duration = duration + sc->sched.channel_switch_time;

ath_dbg(common, CHAN_CTX,
- "oneshot noa_duration: %d, noa_start: %d, noa_index: %d, periodic: %d\n",
+ "oneshot noa_duration: %d, noa_start: %u, noa_index: %d, periodic: %d\n",
avp->noa_duration,
avp->noa_start,
avp->noa_index,
@@ -1401,6 +1401,7 @@ void ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx)

static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
s32 tsf, target_tsf;

@@ -1418,6 +1419,10 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp)
if (target_tsf - tsf < ATH_P2P_PS_STOP_TIME)
target_tsf = tsf + ATH_P2P_PS_STOP_TIME;

+ ath_dbg(common, CHAN_CTX, "%s absent %d tsf 0x%08X next_tsf 0x%08X (%dms)\n",
+ __func__, avp->noa.absent, tsf, target_tsf,
+ (target_tsf - tsf) / 1000);
+
ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 1000000);
}

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index bdfff46..4af19e4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2299,10 +2299,10 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
else
nextTbtt = bs->bs_nexttbtt;

- ath_dbg(common, BEACON, "next DTIM %d\n", bs->bs_nextdtim);
- ath_dbg(common, BEACON, "next beacon %d\n", nextTbtt);
- ath_dbg(common, BEACON, "beacon period %d\n", beaconintval);
- ath_dbg(common, BEACON, "DTIM period %d\n", dtimperiod);
+ ath_dbg(common, BEACON, "next DTIM %u\n", bs->bs_nextdtim);
+ ath_dbg(common, BEACON, "next beacon %u\n", nextTbtt);
+ ath_dbg(common, BEACON, "beacon period %u\n", beaconintval);
+ ath_dbg(common, BEACON, "DTIM period %u\n", dtimperiod);

ENABLE_REGWRITE_BUFFER(ah);

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 3e3dac3..26698a6 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1473,11 +1473,14 @@ static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
u16 tid, u16 *ssn)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_atx_tid *txtid;
struct ath_txq *txq;
struct ath_node *an;
u8 density;

+ ath_dbg(common, XMIT, "%s called\n", __func__);
+
an = (struct ath_node *)sta->drv_priv;
txtid = ATH_AN_2_TID(an, tid);
txq = txtid->txq;
@@ -1512,10 +1515,13 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,

void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_node *an = (struct ath_node *)sta->drv_priv;
struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid);
struct ath_txq *txq = txtid->txq;

+ ath_dbg(common, XMIT, "%s called\n", __func__);
+
ath_txq_lock(sc, txq);
txtid->active = false;
ath_tx_flush_tid(sc, txtid);
@@ -1526,11 +1532,14 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
struct ath_node *an)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_atx_tid *tid;
struct ath_txq *txq;
bool buffered;
int tidno;

+ ath_dbg(common, XMIT, "%s called\n", __func__);
+
for (tidno = 0, tid = &an->tid[tidno];
tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {

@@ -1555,10 +1564,13 @@ void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,

void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_atx_tid *tid;
struct ath_txq *txq;
int tidno;

+ ath_dbg(common, XMIT, "%s called\n", __func__);
+
for (tidno = 0, tid = &an->tid[tidno];
tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {

@@ -1579,10 +1591,13 @@ void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta,
u16 tidno)
{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_atx_tid *tid;
struct ath_node *an;
struct ath_txq *txq;

+ ath_dbg(common, XMIT, "%s called\n", __func__);
+
an = (struct ath_node *)sta->drv_priv;
tid = ATH_AN_2_TID(an, tidno);
txq = tid->txq;
--
1.9.1



2015-11-27 08:37:35

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 09/13] ath9k: request NOA update when chanctx active

Request NOA update when chanctx active, also in case
of STA.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
This depends on:
mac80211: add new IEEE80211_VIF_GET_NOA_UPDATE flag

drivers/net/wireless/ath/ath9k/channel.c | 2 +-
drivers/net/wireless/ath/ath9k/main.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 5a1ede6..c94d7d9 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1439,7 +1439,7 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
if (!sc->p2p_ps_timer)
return;

- if (vif->type != NL80211_IFTYPE_STATION || !vif->p2p)
+ if (vif->type != NL80211_IFTYPE_STATION)
return;

sc->p2p_ps_vif = avp;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index d184e68..ab46a4d 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -974,7 +974,7 @@ static void ath9k_update_bssid_mask(struct ath_softc *sc,
if (ctx->nvifs_assigned != 1)
continue;

- if (!avp->vif->p2p || !iter_data->has_hw_macaddr)
+ if (!iter_data->has_hw_macaddr)
continue;

ether_addr_copy(common->curbssid, avp->bssid);
@@ -1251,6 +1251,9 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
sc->cur_chan->nvifs++;

+ if (vif->type == NL80211_IFTYPE_STATION && ath9k_is_chanctx_enabled())
+ vif->driver_flags |= IEEE80211_VIF_GET_NOA_UPDATE;
+
if (ath9k_uses_beacons(vif->type))
ath9k_beacon_assign_slot(sc, vif);

--
1.9.1


2015-11-27 08:37:41

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 13/13] ath9k: remove ath9k_mod_tsf64_tu

Remove ath9k_mod_tsf64_tu() function while we could
use div_u64_rem() function.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/common-beacon.c | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/common-beacon.c b/drivers/net/wireless/ath/ath9k/common-beacon.c
index 6ad4447..01d6d32 100644
--- a/drivers/net/wireless/ath/ath9k/common-beacon.c
+++ b/drivers/net/wireless/ath/ath9k/common-beacon.c
@@ -18,30 +18,16 @@

#define FUDGE 2

-/* Calculate the modulo of a 64 bit TSF snapshot with a TU divisor */
-static u32 ath9k_mod_tsf64_tu(u64 tsf, u32 div_tu)
-{
- u32 tsf_mod, tsf_hi, tsf_lo, mod_hi, mod_lo;
-
- tsf_mod = tsf & (BIT(10) - 1);
- tsf_hi = tsf >> 32;
- tsf_lo = ((u32) tsf) >> 10;
-
- mod_hi = tsf_hi % div_tu;
- mod_lo = ((mod_hi << 22) + tsf_lo) % div_tu;
-
- return (mod_lo << 10) | tsf_mod;
-}
-
static u32 ath9k_get_next_tbtt(struct ath_hw *ah, u64 tsf,
unsigned int interval)
{
- unsigned int offset;
+ unsigned int offset, divisor;

tsf += TU_TO_USEC(FUDGE + ah->config.sw_beacon_response_time);
- offset = ath9k_mod_tsf64_tu(tsf, interval);
+ divisor = TU_TO_USEC(interval);
+ div_u64_rem(tsf, divisor, &offset);

- return (u32) tsf + TU_TO_USEC(interval) - offset;
+ return (u32) tsf + divisor - offset;
}

/*
--
1.9.1


2015-11-27 08:37:30

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 06/13] ath9k: setup correct skb priority for nullfunc

After queue nullfunc for MCC case, we hit WARN_ON
in xmit.c:2398 while skb priority wasn't set.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 28bbbef..2afb8da 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1101,6 +1101,7 @@ ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp,
nullfunc->frame_control |=
cpu_to_le16(IEEE80211_FCTL_PM);

+ skb->priority = 7;
skb_set_queue_mapping(skb, IEEE80211_AC_VO);
if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) {
dev_kfree_skb_any(skb);
--
1.9.1


2015-11-27 08:37:37

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 10/13] ath9k: MCC, add NOA also in case of an AP

In case of MCC and AP interface, add also NOA attr
that will inform stations about absence of an AP.
There is a chance that some stations will handle
this NOA attr correctly and will know exactly when
AP is present/absent.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/beacon.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index f50a6bc..5cf0cd7 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -148,7 +148,8 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,

ath_assign_seq(common, skb);

- if (vif->p2p)
+ /* Always assign NOA attr when MCC enabled */
+ if (ath9k_is_chanctx_enabled())
ath9k_beacon_add_noa(sc, avp, skb);

bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
--
1.9.1


2015-11-27 08:37:29

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 05/13] ath9k: use u32 when calculate tsf

Use u32 while ath9k_hw_gettsf32() and
ath9k_hw_gen_timer_start() require u32.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 5640e88..28bbbef 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1405,7 +1405,7 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp)
{
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
- s32 tsf, target_tsf;
+ u32 tsf, target_tsf;

if (!avp || !avp->noa.has_next_tsf)
return;
@@ -1427,7 +1427,7 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp)
__func__, avp->noa.absent, tsf, target_tsf,
(target_tsf - tsf) / 1000);

- ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 1000000);
+ ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, target_tsf, 1000000);
}

static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
--
1.9.1


2015-11-27 08:37:26

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 02/13] ath9k: print real timer value

In case of low HZ before this patch we saw wrong
values in debug message. Print real timeout value.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 35802c9..dddaaea 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -356,14 +356,16 @@ static void ath_chanctx_setup_timer(struct ath_softc *sc, u32 tsf_time)
{
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_hw *ah = sc->sc_ah;
+ unsigned long timeout;

ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, 1000000);
tsf_time -= ath9k_hw_gettsf32(ah);
- tsf_time = msecs_to_jiffies(tsf_time / 1000) + 1;
- mod_timer(&sc->sched.timer, jiffies + tsf_time);
+ timeout = msecs_to_jiffies(tsf_time / 1000) + 1;
+ mod_timer(&sc->sched.timer, jiffies + timeout);

ath_dbg(common, CHAN_CTX,
- "Setup chanctx timer with timeout: %d ms\n", jiffies_to_msecs(tsf_time));
+ "Setup chanctx timer with timeout: %d (%d) ms\n",
+ tsf_time / 1000, jiffies_to_msecs(timeout));
}

static void ath_chanctx_handle_bmiss(struct ath_softc *sc,
--
1.9.1


2015-11-27 08:37:39

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 12/13] ath9k: MCC, print time elapsed between events

This is useful for MCC debugging and bug fixing.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/ath9k.h | 1 +
drivers/net/wireless/ath/ath9k/channel.c | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 4616229..952a467 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -983,6 +983,7 @@ struct ath_softc {
struct ath_offchannel offchannel;
struct ath_chanctx *next_chan;
struct completion go_beacon;
+ struct timespec last_event_time;
#endif

unsigned long driver_data;
diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 8ab856c..65ad7be 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -226,6 +226,20 @@ static const char *chanctx_state_string(enum ath_chanctx_state state)
}
}

+static const u32 chanctx_event_delta(struct ath_softc *sc)
+{
+ u64 ms;
+ struct timespec ts, *old;
+
+ getrawmonotonic(&ts);
+ old = &sc->last_event_time;
+ ms = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
+ ms -= old->tv_sec * 1000 + old->tv_nsec / 1000000;
+ sc->last_event_time = ts;
+
+ return (u32)ms;
+}
+
void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
{
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -507,10 +521,11 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,

spin_lock_bh(&sc->chan_lock);

- ath_dbg(common, CHAN_CTX, "cur_chan: %d MHz, event: %s, state: %s\n",
+ ath_dbg(common, CHAN_CTX, "cur_chan: %d MHz, event: %s, state: %s, delta: %u ms\n",
sc->cur_chan->chandef.center_freq1,
chanctx_event_string(ev),
- chanctx_state_string(sc->sched.state));
+ chanctx_state_string(sc->sched.state),
+ chanctx_event_delta(sc));

switch (ev) {
case ATH_CHANCTX_EVENT_BEACON_PREPARE:
--
1.9.1


2015-11-27 08:37:31

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 07/13] ath9k: MCC enable Opportunistic Power Save

When adding NOA attr enable Opportunistic Power Save.
Before we calculate ctwindow but didn't enable oppps.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 2afb8da..31b4d0e 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1505,6 +1505,8 @@ void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp,

noa->index = avp->noa_index;
noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp);
+ if (noa->oppps_ctwindow)
+ noa->oppps_ctwindow |= BIT(7);

if (avp->noa_duration) {
if (avp->periodic_noa) {
--
1.9.1


2015-11-27 08:37:27

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 03/13] ath9k: queue null frames in case of MCC

While mac80211 using null frames when connection polling,
we should queue this frames while NOA could be there, and
AP, P2P_GO could be not present.

Without this patch, with no traffic we often saw disconnections
while we try to send nullfunc when AP/GO wasn't present.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/xmit.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 26698a6..82fc76f 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2331,6 +2331,12 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,

queue = ieee80211_is_data_present(hdr->frame_control);

+ /* If chanctx, queue all null frames while NOA could be there */
+ if (ath9k_is_chanctx_enabled() &&
+ ieee80211_is_nullfunc(hdr->frame_control) &&
+ !txctl->force_channel)
+ queue = true;
+
/* Force queueing of all frames that belong to a virtual interface on
* a different channel context, to ensure that they are sent on the
* correct channel.
--
1.9.1


2015-11-27 08:37:33

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 08/13] ath9k: P2P_CLIENT, get/set NOA correctly

In case we get BSS_CHANGED_P2P_PS early, from
mac80211, we didn't set NOA timer correctly,
while p2p_ps_vif was NULL.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 31b4d0e..5a1ede6 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1443,6 +1443,10 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
return;

sc->p2p_ps_vif = avp;
+
+ if (sc->ps_flags & PS_BEACON_SYNC)
+ return;
+
tsf = ath9k_hw_gettsf32(sc->sc_ah);
ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
ath9k_update_p2p_ps_timer(sc, avp);
@@ -1585,8 +1589,7 @@ void ath9k_p2p_bss_info_changed(struct ath_softc *sc,

spin_lock_bh(&sc->sc_pcu_lock);
spin_lock_irqsave(&sc->sc_pm_lock, flags);
- if (!(sc->ps_flags & PS_BEACON_SYNC))
- ath9k_update_p2p_ps(sc, vif);
+ ath9k_update_p2p_ps(sc, vif);
spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
spin_unlock_bh(&sc->sc_pcu_lock);
}
--
1.9.1


2015-11-27 08:37:28

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH v2 04/13] ath9k: P2P_CLIENT, send frames after 1ms AP/GO will aprear

AP/GO will aprear after NOA, wait 1ms to be sure AP
could receive/answer this frames.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
drivers/net/wireless/ath/ath9k/channel.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index dddaaea..5640e88 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1417,6 +1417,8 @@ static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp)
target_tsf = avp->noa.next_tsf;
if (!avp->noa.absent)
target_tsf -= ATH_P2P_PS_STOP_TIME;
+ else
+ target_tsf += ATH_P2P_PS_STOP_TIME;

if (target_tsf - tsf < ATH_P2P_PS_STOP_TIME)
target_tsf = tsf + ATH_P2P_PS_STOP_TIME;
@@ -1543,6 +1545,8 @@ void ath9k_p2p_ps_timer(void *priv)
tsf = ath9k_hw_gettsf32(sc->sc_ah);
if (!avp->noa.absent)
tsf += ATH_P2P_PS_STOP_TIME;
+ else
+ tsf -= ATH_P2P_PS_STOP_TIME;

if (!avp->noa.has_next_tsf ||
avp->noa.next_tsf - tsf > BIT(31))
--
1.9.1


2015-11-27 08:37:39

by Janusz Dziedzic

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

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 <[email protected]>
---
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


2015-12-11 08:19:18

by Kalle Valo

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

Janusz Dziedzic <[email protected]> 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 <[email protected]>

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

2015-12-01 13:13:33

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2 09/13] ath9k: request NOA update when chanctx active

Janusz Dziedzic <[email protected]> writes:

> Request NOA update when chanctx active, also in case
> of STA.
>
> Signed-off-by: Janusz Dziedzic <[email protected]>
> ---
> This depends on:
> mac80211: add new IEEE80211_VIF_GET_NOA_UPDATE flag

It would make my life a lot easier if you could submit patches like this
(which depend on something else) in a separate patchset instead of
hiding them inside a 13 patch set. I'll postpone this patch for now and
apply it once I have the mac80211 commit.

--
Kalle Valo

2015-12-17 09:44:45

by Janusz Dziedzic

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

On 11 December 2015 at 09:19, Kalle Valo <[email protected]> wrote:
> Janusz Dziedzic <[email protected]> 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 <[email protected]>
>
> 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

2015-12-08 15:03:25

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2 01/13] ath9k: add debug messages to aggr/chanctx funcs

Janusz Dziedzic <[email protected]> writes:

> Add/extend debug messages when chanctx used.
>
> Signed-off-by: Janusz Dziedzic <[email protected]>

Manually applied these patches to ath.git:

05a85a6c42b5 ath9k: remove ath9k_mod_tsf64_tu
02edab5b5f82 ath9k: MCC, print time elapsed between events
a64d876ef7dc ath9k: MCC, add NOA also in case of an AP
b10b7fb31a21 ath9k: P2P_CLIENT, get/set NOA correctly
3edbf0ba0494 ath9k: MCC enable Opportunistic Power Save
c1b7bea038f0 ath9k: setup correct skb priority for nullfunc
631c45f41957 ath9k: use u32 when calculate tsf
b77b59ae8acd ath9k: P2P_CLIENT, send frames after 1ms AP/GO will aprear
60337ed86306 ath9k: queue null frames in case of MCC
2f985539b98b ath9k: print real timer value
58bb9ca84c20 ath9k: add debug messages to aggr/chanctx funcs

These patches are still pending:

[v2,09/13] ath9k: request NOA update when chanctx active
[v2,11/13] ath9k: MCC add sta_ap_ratio module param

--
Kalle Valo

2016-01-28 08:21:54

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2 09/13] ath9k: request NOA update when chanctx active

Janusz Dziedzic <[email protected]> writes:

> Request NOA update when chanctx active, also in case
> of STA.
>
> Signed-off-by: Janusz Dziedzic <[email protected]>
> ---
> This depends on:
> mac80211: add new IEEE80211_VIF_GET_NOA_UPDATE flag

The dependency is now in ath.git and I have applied this, thanks.

--
Kalle Valo