mac80211: merge a few pending upstream fixes
[openwrt/staging/hauke.git] / package / kernel / mac80211 / patches / 322-ath9k-Send-oneshot-NoA.patch
1 From: Sujith Manoharan <c_manoha@qca.qualcomm.com>
2 Date: Fri, 17 Oct 2014 07:40:27 +0530
3 Subject: [PATCH] ath9k: Send oneshot NoA
4
5 This patch makes sure that a GO interface
6 sends out a new NoA schedule with 200ms duration
7 when mgd_prepare_tx() is called.
8
9 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
10 ---
11
12 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
13 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
14 @@ -620,6 +620,7 @@ struct ath_vif {
15 u32 noa_start;
16 u32 noa_duration;
17 bool periodic_noa;
18 + bool oneshot_noa;
19 };
20
21 struct ath9k_vif_iter_data {
22 --- a/drivers/net/wireless/ath/ath9k/channel.c
23 +++ b/drivers/net/wireless/ath/ath9k/channel.c
24 @@ -450,6 +450,27 @@ static void ath_chanctx_set_periodic_noa
25 avp->periodic_noa);
26 }
27
28 +static void ath_chanctx_set_oneshot_noa(struct ath_softc *sc,
29 + struct ath_vif *avp,
30 + u32 tsf_time,
31 + u32 duration)
32 +{
33 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
34 +
35 + avp->noa_index++;
36 + avp->noa_start = tsf_time;
37 + avp->periodic_noa = false;
38 + avp->oneshot_noa = true;
39 + avp->noa_duration = duration + sc->sched.channel_switch_time;
40 +
41 + ath_dbg(common, CHAN_CTX,
42 + "oneshot noa_duration: %d, noa_start: %d, noa_index: %d, periodic: %d\n",
43 + avp->noa_duration,
44 + avp->noa_start,
45 + avp->noa_index,
46 + avp->periodic_noa);
47 +}
48 +
49 void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
50 enum ath_chanctx_event ev)
51 {
52 @@ -476,6 +497,14 @@ void ath_chanctx_event(struct ath_softc
53 if (avp->offchannel_duration)
54 avp->offchannel_duration = 0;
55
56 + if (avp->oneshot_noa) {
57 + avp->noa_duration = 0;
58 + avp->oneshot_noa = false;
59 +
60 + ath_dbg(common, CHAN_CTX,
61 + "Clearing oneshot NoA\n");
62 + }
63 +
64 if (avp->chanctx != sc->cur_chan) {
65 ath_dbg(common, CHAN_CTX,
66 "Contexts differ, not preparing beacon\n");
67 @@ -551,6 +580,18 @@ void ath_chanctx_event(struct ath_softc
68
69 ath_chanctx_handle_bmiss(sc, ctx, avp);
70
71 + /*
72 + * If a mgd_prepare_tx() has been called by mac80211,
73 + * a one-shot NoA needs to be sent. This can happen
74 + * with one or more active channel contexts - in both
75 + * cases, a new NoA schedule has to be advertised.
76 + */
77 + if (sc->sched.mgd_prepare_tx) {
78 + ath_chanctx_set_oneshot_noa(sc, avp, tsf_time,
79 + jiffies_to_usecs(HZ / 5));
80 + break;
81 + }
82 +
83 /* Prevent wrap-around issues */
84 if (avp->noa_duration && tsf_time - avp->noa_start > BIT(30))
85 avp->noa_duration = 0;