diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-06-11 06:48:06 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-06-19 15:49:19 -0400 |
commit | 3ae07d39ea81440768427e7786c5422f3af38a94 (patch) | |
tree | 1a1da597c444c3cc3d8985e634f76bd341b8a6d7 | |
parent | ea6ff2de5c56f6b0c08717f6cc47281b52504e81 (diff) |
ath9k: Add p2p go NoA attribute
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>
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ath9k.h | 7 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/beacon.c | 37 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/channel.c | 39 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/init.c | 2 |
4 files changed, 80 insertions, 5 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 6487c4769af4..02f30980c31a 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -362,6 +362,8 @@ struct ath_chanctx_sched { | |||
362 | enum ath_chanctx_state state; | 362 | enum ath_chanctx_state state; |
363 | 363 | ||
364 | u32 next_tbtt; | 364 | u32 next_tbtt; |
365 | u32 switch_start_time; | ||
366 | unsigned int offchannel_duration; | ||
365 | unsigned int channel_switch_time; | 367 | unsigned int channel_switch_time; |
366 | }; | 368 | }; |
367 | 369 | ||
@@ -472,6 +474,11 @@ struct ath_vif { | |||
472 | 474 | ||
473 | /* P2P Client */ | 475 | /* P2P Client */ |
474 | struct ieee80211_noa_data noa; | 476 | struct ieee80211_noa_data noa; |
477 | |||
478 | /* P2P GO */ | ||
479 | u8 noa_index; | ||
480 | u32 offchannel_start; | ||
481 | u32 offchannel_duration; | ||
475 | }; | 482 | }; |
476 | 483 | ||
477 | struct ath9k_vif_iter_data { | 484 | struct ath9k_vif_iter_data { |
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 5b1689cf029a..85a40d749e20 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c | |||
@@ -108,6 +108,40 @@ static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif, | |||
108 | ath9k_hw_set_txdesc(ah, bf->bf_desc, &info); | 108 | ath9k_hw_set_txdesc(ah, bf->bf_desc, &info); |
109 | } | 109 | } |
110 | 110 | ||
111 | static void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, | ||
112 | struct sk_buff *skb) | ||
113 | { | ||
114 | static const u8 noa_ie_hdr[] = { | ||
115 | WLAN_EID_VENDOR_SPECIFIC, /* type */ | ||
116 | 0, /* length */ | ||
117 | 0x50, 0x6f, 0x9a, /* WFA OUI */ | ||
118 | 0x09, /* P2P subtype */ | ||
119 | 0x0c, /* Notice of Absence */ | ||
120 | 0x00, /* LSB of little-endian len */ | ||
121 | 0x00, /* MSB of little-endian len */ | ||
122 | }; | ||
123 | |||
124 | struct ieee80211_p2p_noa_attr *noa; | ||
125 | int noa_len = 2 + sizeof(struct ieee80211_p2p_noa_desc); | ||
126 | u8 *hdr; | ||
127 | |||
128 | if (!avp->offchannel_duration) | ||
129 | return; | ||
130 | |||
131 | hdr = skb_put(skb, sizeof(noa_ie_hdr)); | ||
132 | memcpy(hdr, noa_ie_hdr, sizeof(noa_ie_hdr)); | ||
133 | hdr[1] = sizeof(noa_ie_hdr) + noa_len - 2; | ||
134 | hdr[7] = noa_len; | ||
135 | |||
136 | noa = (void *) skb_put(skb, noa_len); | ||
137 | memset(noa, 0, noa_len); | ||
138 | |||
139 | noa->index = avp->noa_index; | ||
140 | noa->desc[0].count = 1; | ||
141 | noa->desc[0].duration = cpu_to_le32(avp->offchannel_duration); | ||
142 | noa->desc[0].start_time = cpu_to_le32(avp->offchannel_start); | ||
143 | } | ||
144 | |||
111 | static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, | 145 | static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, |
112 | struct ieee80211_vif *vif) | 146 | struct ieee80211_vif *vif) |
113 | { | 147 | { |
@@ -155,6 +189,9 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, | |||
155 | hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no); | 189 | hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no); |
156 | } | 190 | } |
157 | 191 | ||
192 | if (vif->p2p) | ||
193 | ath9k_beacon_add_noa(sc, avp, skb); | ||
194 | |||
158 | bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, | 195 | bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, |
159 | skb->len, DMA_TO_DEVICE); | 196 | skb->len, DMA_TO_DEVICE); |
160 | if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { | 197 | if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { |
diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c index 503b7766e12e..364a55502b7d 100644 --- a/drivers/net/wireless/ath/ath9k/channel.c +++ b/drivers/net/wireless/ath/ath9k/channel.c | |||
@@ -270,6 +270,8 @@ void ath_chanctx_work(struct work_struct *work) | |||
270 | sc->cur_chan->stopped = false; | 270 | sc->cur_chan->stopped = false; |
271 | sc->next_chan = NULL; | 271 | sc->next_chan = NULL; |
272 | sc->sched.state = ATH_CHANCTX_STATE_IDLE; | 272 | sc->sched.state = ATH_CHANCTX_STATE_IDLE; |
273 | sc->sched.offchannel_duration = 0; | ||
274 | |||
273 | spin_unlock_bh(&sc->chan_lock); | 275 | spin_unlock_bh(&sc->chan_lock); |
274 | 276 | ||
275 | if (sc->sc_ah->chip_fullsleep || | 277 | if (sc->sc_ah->chip_fullsleep || |
@@ -326,6 +328,12 @@ void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx, | |||
326 | sc->next_chan = ctx; | 328 | sc->next_chan = ctx; |
327 | if (chandef) | 329 | if (chandef) |
328 | ctx->chandef = *chandef; | 330 | ctx->chandef = *chandef; |
331 | |||
332 | if (sc->next_chan == &sc->offchannel.chan) { | ||
333 | sc->sched.offchannel_duration = | ||
334 | TU_TO_USEC(sc->offchannel.duration) + | ||
335 | sc->sched.channel_switch_time; | ||
336 | } | ||
329 | spin_unlock_bh(&sc->chan_lock); | 337 | spin_unlock_bh(&sc->chan_lock); |
330 | ieee80211_queue_work(sc->hw, &sc->chanctx_work); | 338 | ieee80211_queue_work(sc->hw, &sc->chanctx_work); |
331 | } | 339 | } |
@@ -377,17 +385,40 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, | |||
377 | enum ath_chanctx_event ev) | 385 | enum ath_chanctx_event ev) |
378 | { | 386 | { |
379 | struct ath_hw *ah = sc->sc_ah; | 387 | struct ath_hw *ah = sc->sc_ah; |
388 | struct ath_vif *avp = NULL; | ||
380 | u32 tsf_time; | 389 | u32 tsf_time; |
390 | bool noa_changed = false; | ||
391 | |||
392 | if (vif) | ||
393 | avp = (struct ath_vif *) vif->drv_priv; | ||
381 | 394 | ||
382 | spin_lock_bh(&sc->chan_lock); | 395 | spin_lock_bh(&sc->chan_lock); |
383 | 396 | ||
384 | switch (ev) { | 397 | switch (ev) { |
385 | case ATH_CHANCTX_EVENT_BEACON_PREPARE: | 398 | case ATH_CHANCTX_EVENT_BEACON_PREPARE: |
399 | if (avp->offchannel_duration) | ||
400 | avp->offchannel_duration = 0; | ||
401 | |||
386 | if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) | 402 | if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) |
387 | break; | 403 | break; |
388 | 404 | ||
389 | sc->sched.beacon_pending = true; | 405 | sc->sched.beacon_pending = true; |
390 | sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER); | 406 | sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER); |
407 | |||
408 | /* defer channel switch by a quarter beacon interval */ | ||
409 | tsf_time = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); | ||
410 | tsf_time = sc->sched.next_tbtt + tsf_time / 4; | ||
411 | sc->sched.switch_start_time = tsf_time; | ||
412 | |||
413 | if (sc->sched.offchannel_duration) { | ||
414 | noa_changed = true; | ||
415 | avp->offchannel_start = tsf_time; | ||
416 | avp->offchannel_duration = | ||
417 | sc->sched.offchannel_duration; | ||
418 | } | ||
419 | |||
420 | if (noa_changed) | ||
421 | avp->noa_index++; | ||
391 | break; | 422 | break; |
392 | case ATH_CHANCTX_EVENT_BEACON_SENT: | 423 | case ATH_CHANCTX_EVENT_BEACON_SENT: |
393 | if (!sc->sched.beacon_pending) | 424 | if (!sc->sched.beacon_pending) |
@@ -397,12 +428,10 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, | |||
397 | if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) | 428 | if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) |
398 | break; | 429 | break; |
399 | 430 | ||
400 | /* defer channel switch by a quarter beacon interval */ | ||
401 | tsf_time = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); | ||
402 | tsf_time = sc->sched.next_tbtt + tsf_time / 4; | ||
403 | sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; | 431 | sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; |
404 | ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, | 432 | ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, |
405 | 1000000); | 433 | sc->sched.switch_start_time, |
434 | 1000000); | ||
406 | break; | 435 | break; |
407 | case ATH_CHANCTX_EVENT_TSF_TIMER: | 436 | case ATH_CHANCTX_EVENT_TSF_TIMER: |
408 | if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_TIMER) | 437 | if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_TIMER) |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 1ff1a75f4fed..66a9dc3a5369 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -754,6 +754,8 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
754 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; | 754 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; |
755 | hw->wiphy->max_remain_on_channel_duration = 10000; | 755 | hw->wiphy->max_remain_on_channel_duration = 10000; |
756 | hw->chanctx_data_size = sizeof(void *); | 756 | hw->chanctx_data_size = sizeof(void *); |
757 | hw->extra_beacon_tailroom = | ||
758 | sizeof(struct ieee80211_p2p_noa_attr) + 9; | ||
757 | } | 759 | } |
758 | } | 760 | } |
759 | 761 | ||