diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-06-11 06:48:11 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-06-19 15:49:20 -0400 |
commit | 7414863ed3dfa407006c92616c1e0efda481738c (patch) | |
tree | 22a536107934c24d1c8f0c8e4c264eaf61c362be /drivers/net/wireless | |
parent | 73fa2f26d35a37034fdff9fd702887909e138926 (diff) |
ath9k: Add periodic NoA support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ath9k.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/beacon.c | 25 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/channel.c | 24 |
3 files changed, 44 insertions, 8 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 0bc63bd4ec26..a5afd4a7df9f 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -489,6 +489,9 @@ struct ath_vif { | |||
489 | u8 noa_index; | 489 | u8 noa_index; |
490 | u32 offchannel_start; | 490 | u32 offchannel_start; |
491 | u32 offchannel_duration; | 491 | u32 offchannel_duration; |
492 | |||
493 | u32 periodic_noa_start; | ||
494 | u32 periodic_noa_duration; | ||
492 | }; | 495 | }; |
493 | 496 | ||
494 | struct ath9k_vif_iter_data { | 497 | struct ath9k_vif_iter_data { |
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 85a40d749e20..eaf8f058c151 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c | |||
@@ -122,12 +122,15 @@ static void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, | |||
122 | }; | 122 | }; |
123 | 123 | ||
124 | struct ieee80211_p2p_noa_attr *noa; | 124 | struct ieee80211_p2p_noa_attr *noa; |
125 | int noa_len = 2 + sizeof(struct ieee80211_p2p_noa_desc); | 125 | int noa_len, noa_desc, i = 0; |
126 | u8 *hdr; | 126 | u8 *hdr; |
127 | 127 | ||
128 | if (!avp->offchannel_duration) | 128 | if (!avp->offchannel_duration && !avp->periodic_noa_duration) |
129 | return; | 129 | return; |
130 | 130 | ||
131 | noa_desc = !!avp->offchannel_duration + !!avp->periodic_noa_duration; | ||
132 | noa_len = 2 + sizeof(struct ieee80211_p2p_noa_desc) * noa_desc; | ||
133 | |||
131 | hdr = skb_put(skb, sizeof(noa_ie_hdr)); | 134 | hdr = skb_put(skb, sizeof(noa_ie_hdr)); |
132 | memcpy(hdr, noa_ie_hdr, sizeof(noa_ie_hdr)); | 135 | memcpy(hdr, noa_ie_hdr, sizeof(noa_ie_hdr)); |
133 | hdr[1] = sizeof(noa_ie_hdr) + noa_len - 2; | 136 | hdr[1] = sizeof(noa_ie_hdr) + noa_len - 2; |
@@ -137,9 +140,21 @@ static void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, | |||
137 | memset(noa, 0, noa_len); | 140 | memset(noa, 0, noa_len); |
138 | 141 | ||
139 | noa->index = avp->noa_index; | 142 | noa->index = avp->noa_index; |
140 | noa->desc[0].count = 1; | 143 | if (avp->periodic_noa_duration) { |
141 | noa->desc[0].duration = cpu_to_le32(avp->offchannel_duration); | 144 | u32 interval = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); |
142 | noa->desc[0].start_time = cpu_to_le32(avp->offchannel_start); | 145 | |
146 | noa->desc[i].count = 255; | ||
147 | noa->desc[i].start_time = cpu_to_le32(avp->periodic_noa_start); | ||
148 | noa->desc[i].duration = cpu_to_le32(avp->periodic_noa_duration); | ||
149 | noa->desc[i].interval = cpu_to_le32(interval); | ||
150 | i++; | ||
151 | } | ||
152 | |||
153 | if (avp->offchannel_duration) { | ||
154 | noa->desc[i].count = 1; | ||
155 | noa->desc[i].start_time = cpu_to_le32(avp->offchannel_start); | ||
156 | noa->desc[i].duration = cpu_to_le32(avp->offchannel_duration); | ||
157 | } | ||
143 | } | 158 | } |
144 | 159 | ||
145 | static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, | 160 | static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, |
diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c index 1cb2909a114c..3d9776c4c909 100644 --- a/drivers/net/wireless/ath/ath9k/channel.c +++ b/drivers/net/wireless/ath/ath9k/channel.c | |||
@@ -474,6 +474,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, | |||
474 | { | 474 | { |
475 | struct ath_hw *ah = sc->sc_ah; | 475 | struct ath_hw *ah = sc->sc_ah; |
476 | struct ath_common *common = ath9k_hw_common(ah); | 476 | struct ath_common *common = ath9k_hw_common(ah); |
477 | struct ath_beacon_config *cur_conf; | ||
477 | struct ath_vif *avp = NULL; | 478 | struct ath_vif *avp = NULL; |
478 | struct ath_chanctx *ctx; | 479 | struct ath_chanctx *ctx; |
479 | u32 tsf_time; | 480 | u32 tsf_time; |
@@ -514,12 +515,29 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, | |||
514 | sc->sched.beacon_pending = true; | 515 | sc->sched.beacon_pending = true; |
515 | sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER); | 516 | sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER); |
516 | 517 | ||
518 | cur_conf = &sc->cur_chan->beacon; | ||
517 | /* defer channel switch by a quarter beacon interval */ | 519 | /* defer channel switch by a quarter beacon interval */ |
518 | tsf_time = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); | 520 | tsf_time = TU_TO_USEC(cur_conf->beacon_interval); |
519 | tsf_time = sc->sched.next_tbtt + tsf_time / 4; | 521 | tsf_time = sc->sched.next_tbtt + tsf_time / 4; |
520 | sc->sched.switch_start_time = tsf_time; | 522 | sc->sched.switch_start_time = tsf_time; |
521 | sc->cur_chan->last_beacon = sc->sched.next_tbtt; | 523 | sc->cur_chan->last_beacon = sc->sched.next_tbtt; |
522 | 524 | ||
525 | /* Prevent wrap-around issues */ | ||
526 | if (avp->periodic_noa_duration && | ||
527 | tsf_time - avp->periodic_noa_start > BIT(30)) | ||
528 | avp->periodic_noa_duration = 0; | ||
529 | |||
530 | if (ctx->active && !avp->periodic_noa_duration) { | ||
531 | avp->periodic_noa_start = tsf_time; | ||
532 | avp->periodic_noa_duration = | ||
533 | TU_TO_USEC(cur_conf->beacon_interval) / 2 - | ||
534 | sc->sched.channel_switch_time; | ||
535 | noa_changed = true; | ||
536 | } else if (!ctx->active && avp->periodic_noa_duration) { | ||
537 | avp->periodic_noa_duration = 0; | ||
538 | noa_changed = true; | ||
539 | } | ||
540 | |||
523 | if (sc->sched.offchannel_duration) { | 541 | if (sc->sched.offchannel_duration) { |
524 | noa_changed = true; | 542 | noa_changed = true; |
525 | avp->offchannel_start = tsf_time; | 543 | avp->offchannel_start = tsf_time; |
@@ -575,11 +593,11 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, | |||
575 | * beacon period (minus channel switch time) | 593 | * beacon period (minus channel switch time) |
576 | */ | 594 | */ |
577 | sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan); | 595 | sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan); |
596 | cur_conf = &sc->cur_chan->beacon; | ||
578 | 597 | ||
579 | sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; | 598 | sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; |
580 | tsf_time = ath9k_hw_gettsf32(sc->sc_ah); | 599 | tsf_time = ath9k_hw_gettsf32(sc->sc_ah); |
581 | tsf_time += | 600 | tsf_time += TU_TO_USEC(cur_conf->beacon_interval) / 2; |
582 | TU_TO_USEC(sc->cur_chan->beacon.beacon_interval) / 2; | ||
583 | tsf_time -= sc->sched.channel_switch_time; | 601 | tsf_time -= sc->sched.channel_switch_time; |
584 | sc->sched.switch_start_time = tsf_time; | 602 | sc->sched.switch_start_time = tsf_time; |
585 | 603 | ||