aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k
diff options
context:
space:
mode:
authorSujith <Sujith.Manoharan@atheros.com>2008-09-17 00:45:09 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-24 16:18:01 -0400
commit980b24da6f1725c2d0b32c9484d06cd7d09d3c4b (patch)
tree2e7190bc7ceedf21f01e5fe6dd02d68870a96e63 /drivers/net/wireless/ath9k
parent42eb7c644afcdbcd7eac4d862046230856fbf531 (diff)
ath9k: Whitespace cleanup
Also, remove comments that are not relevant anymore. Signed-off-by: Sujith <Sujith.Manoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k')
-rw-r--r--drivers/net/wireless/ath9k/beacon.c136
1 files changed, 60 insertions, 76 deletions
diff --git a/drivers/net/wireless/ath9k/beacon.c b/drivers/net/wireless/ath9k/beacon.c
index c43fd5861163..f8d952ca3f85 100644
--- a/drivers/net/wireless/ath9k/beacon.c
+++ b/drivers/net/wireless/ath9k/beacon.c
@@ -26,7 +26,6 @@
26 * the operating mode of the station (AP or AdHoc). Parameters are AIFS 26 * the operating mode of the station (AP or AdHoc). Parameters are AIFS
27 * settings and channel width min/max 27 * settings and channel width min/max
28*/ 28*/
29
30static int ath_beaconq_config(struct ath_softc *sc) 29static int ath_beaconq_config(struct ath_softc *sc)
31{ 30{
32 struct ath_hal *ah = sc->sc_ah; 31 struct ath_hal *ah = sc->sc_ah;
@@ -63,19 +62,18 @@ static int ath_beaconq_config(struct ath_softc *sc)
63 * up all required antenna switch parameters, rate codes, and channel flags. 62 * up all required antenna switch parameters, rate codes, and channel flags.
64 * Beacons are always sent out at the lowest rate, and are not retried. 63 * Beacons are always sent out at the lowest rate, and are not retried.
65*/ 64*/
66
67static void ath_beacon_setup(struct ath_softc *sc, 65static void ath_beacon_setup(struct ath_softc *sc,
68 struct ath_vap *avp, struct ath_buf *bf) 66 struct ath_vap *avp, struct ath_buf *bf)
69{ 67{
70 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu; 68 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
71 struct ath_hal *ah = sc->sc_ah; 69 struct ath_hal *ah = sc->sc_ah;
72 struct ath_desc *ds; 70 struct ath_desc *ds;
73 int flags, antenna; 71 struct ath9k_11n_rate_series series[4];
74 const struct ath9k_rate_table *rt; 72 const struct ath9k_rate_table *rt;
73 int flags, antenna;
75 u8 rix, rate; 74 u8 rix, rate;
76 int ctsrate = 0; 75 int ctsrate = 0;
77 int ctsduration = 0; 76 int ctsduration = 0;
78 struct ath9k_11n_rate_series series[4];
79 77
80 DPRINTF(sc, ATH_DBG_BEACON, "%s: m %p len %u\n", 78 DPRINTF(sc, ATH_DBG_BEACON, "%s: m %p len %u\n",
81 __func__, skb, skb->len); 79 __func__, skb, skb->len);
@@ -115,20 +113,21 @@ static void ath_beacon_setup(struct ath_softc *sc,
115 rate |= rt->info[rix].shortPreamble; 113 rate |= rt->info[rix].shortPreamble;
116 114
117 ath9k_hw_set11n_txdesc(ah, ds, 115 ath9k_hw_set11n_txdesc(ah, ds,
118 skb->len + FCS_LEN, /* frame length */ 116 skb->len + FCS_LEN, /* frame length */
119 ATH9K_PKT_TYPE_BEACON, /* Atheros packet type */ 117 ATH9K_PKT_TYPE_BEACON, /* Atheros packet type */
120 avp->av_btxctl.txpower, /* txpower XXX */ 118 avp->av_btxctl.txpower, /* txpower XXX */
121 ATH9K_TXKEYIX_INVALID, /* no encryption */ 119 ATH9K_TXKEYIX_INVALID, /* no encryption */
122 ATH9K_KEY_TYPE_CLEAR, /* no encryption */ 120 ATH9K_KEY_TYPE_CLEAR, /* no encryption */
123 flags /* no ack, veol for beacons */ 121 flags /* no ack,
122 veol for beacons */
124 ); 123 );
125 124
126 /* NB: beacon's BufLen must be a multiple of 4 bytes */ 125 /* NB: beacon's BufLen must be a multiple of 4 bytes */
127 ath9k_hw_filltxdesc(ah, ds, 126 ath9k_hw_filltxdesc(ah, ds,
128 roundup(skb->len, 4), /* buffer length */ 127 roundup(skb->len, 4), /* buffer length */
129 true, /* first segment */ 128 true, /* first segment */
130 true, /* last segment */ 129 true, /* last segment */
131 ds /* first descriptor */ 130 ds /* first descriptor */
132 ); 131 );
133 132
134 memzero(series, sizeof(struct ath9k_11n_rate_series) * 4); 133 memzero(series, sizeof(struct ath9k_11n_rate_series) * 4);
@@ -153,22 +152,23 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
153 struct ath_buf *bf; 152 struct ath_buf *bf;
154 struct ath_vap *avp; 153 struct ath_vap *avp;
155 struct sk_buff *skb; 154 struct sk_buff *skb;
156 int cabq_depth;
157 struct ath_txq *cabq; 155 struct ath_txq *cabq;
158 struct ieee80211_tx_info *info; 156 struct ieee80211_tx_info *info;
157 int cabq_depth;
158
159 avp = sc->sc_vaps[if_id]; 159 avp = sc->sc_vaps[if_id];
160 ASSERT(avp);
160 161
161 cabq = sc->sc_cabq; 162 cabq = sc->sc_cabq;
162 163
163 ASSERT(avp);
164
165 if (avp->av_bcbuf == NULL) { 164 if (avp->av_bcbuf == NULL) {
166 DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n", 165 DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n",
167 __func__, avp, avp->av_bcbuf); 166 __func__, avp, avp->av_bcbuf);
168 return NULL; 167 return NULL;
169 } 168 }
169
170 bf = avp->av_bcbuf; 170 bf = avp->av_bcbuf;
171 skb = (struct sk_buff *) bf->bf_mpdu; 171 skb = (struct sk_buff *)bf->bf_mpdu;
172 if (skb) { 172 if (skb) {
173 pci_unmap_single(sc->pdev, bf->bf_dmacontext, 173 pci_unmap_single(sc->pdev, bf->bf_dmacontext,
174 skb_end_pointer(skb) - skb->head, 174 skb_end_pointer(skb) - skb->head,
@@ -179,17 +179,19 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
179 bf->bf_mpdu = skb; 179 bf->bf_mpdu = skb;
180 if (skb == NULL) 180 if (skb == NULL)
181 return NULL; 181 return NULL;
182
182 info = IEEE80211_SKB_CB(skb); 183 info = IEEE80211_SKB_CB(skb);
183 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 184 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
184 /* 185 /*
185 * TODO: make sure the seq# gets assigned properly (vs. other 186 * TODO: make sure the seq# gets assigned properly (vs. other
186 * TX frames) 187 * TX frames)
187 */ 188 */
188 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 189 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
189 sc->seq_no += 0x10; 190 sc->seq_no += 0x10;
190 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 191 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
191 hdr->seq_ctrl |= cpu_to_le16(sc->seq_no); 192 hdr->seq_ctrl |= cpu_to_le16(sc->seq_no);
192 } 193 }
194
193 bf->bf_buf_addr = bf->bf_dmacontext = 195 bf->bf_buf_addr = bf->bf_dmacontext =
194 pci_map_single(sc->pdev, skb->data, 196 pci_map_single(sc->pdev, skb->data,
195 skb_end_pointer(skb) - skb->head, 197 skb_end_pointer(skb) - skb->head,
@@ -241,7 +243,6 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
241 * Startup beacon transmission for adhoc mode when they are sent entirely 243 * Startup beacon transmission for adhoc mode when they are sent entirely
242 * by the hardware using the self-linked descriptor + veol trick. 244 * by the hardware using the self-linked descriptor + veol trick.
243*/ 245*/
244
245static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id) 246static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
246{ 247{
247 struct ath_hal *ah = sc->sc_ah; 248 struct ath_hal *ah = sc->sc_ah;
@@ -278,7 +279,6 @@ static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
278 * min/max, and enable aifs). The info structure does not need to be 279 * min/max, and enable aifs). The info structure does not need to be
279 * persistant. 280 * persistant.
280*/ 281*/
281
282int ath_beaconq_setup(struct ath_hal *ah) 282int ath_beaconq_setup(struct ath_hal *ah)
283{ 283{
284 struct ath9k_tx_queue_info qi; 284 struct ath9k_tx_queue_info qi;
@@ -299,11 +299,10 @@ int ath_beaconq_setup(struct ath_hal *ah)
299 * the ATH interface. This routine also calculates the beacon "slot" for 299 * the ATH interface. This routine also calculates the beacon "slot" for
300 * staggared beacons in the mBSSID case. 300 * staggared beacons in the mBSSID case.
301*/ 301*/
302
303int ath_beacon_alloc(struct ath_softc *sc, int if_id) 302int ath_beacon_alloc(struct ath_softc *sc, int if_id)
304{ 303{
305 struct ath_vap *avp; 304 struct ath_vap *avp;
306 struct ieee80211_hdr *wh; 305 struct ieee80211_hdr *hdr;
307 struct ath_buf *bf; 306 struct ath_buf *bf;
308 struct sk_buff *skb; 307 struct sk_buff *skb;
309 308
@@ -312,13 +311,11 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
312 311
313 /* Allocate a beacon descriptor if we haven't done so. */ 312 /* Allocate a beacon descriptor if we haven't done so. */
314 if (!avp->av_bcbuf) { 313 if (!avp->av_bcbuf) {
315 /* 314 /* Allocate beacon state for hostap/ibss. We know
316 * Allocate beacon state for hostap/ibss. We know 315 * a buffer is available. */
317 * a buffer is available.
318 */
319 316
320 avp->av_bcbuf = list_first_entry(&sc->sc_bbuf, 317 avp->av_bcbuf = list_first_entry(&sc->sc_bbuf,
321 struct ath_buf, list); 318 struct ath_buf, list);
322 list_del(&avp->av_bcbuf->list); 319 list_del(&avp->av_bcbuf->list);
323 320
324 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP || 321 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP ||
@@ -362,9 +359,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
362 } 359 }
363 360
364 /* 361 /*
365 * NB: the beacon data buffer must be 32-bit aligned; 362 * NB: the beacon data buffer must be 32-bit aligned.
366 * we assume the wbuf routines will return us something
367 * with this alignment (perhaps should assert).
368 * FIXME: Fill avp->av_btxctl.txpower and 363 * FIXME: Fill avp->av_btxctl.txpower and
369 * avp->av_btxctl.shortPreamble 364 * avp->av_btxctl.shortPreamble
370 */ 365 */
@@ -408,8 +403,8 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
408 __func__, "stagger", 403 __func__, "stagger",
409 avp->av_bslot, intval, (unsigned long long)tsfadjust); 404 avp->av_bslot, intval, (unsigned long long)tsfadjust);
410 405
411 wh = (struct ieee80211_hdr *)skb->data; 406 hdr = (struct ieee80211_hdr *)skb->data;
412 memcpy(&wh[1], &val, sizeof(val)); 407 memcpy(&hdr[1], &val, sizeof(val));
413 } 408 }
414 409
415 bf->bf_buf_addr = bf->bf_dmacontext = 410 bf->bf_buf_addr = bf->bf_dmacontext =
@@ -425,9 +420,8 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
425 * Reclaim beacon resources and return buffer to the pool. 420 * Reclaim beacon resources and return buffer to the pool.
426 * 421 *
427 * Checks the VAP to put the beacon frame buffer back to the ATH object 422 * Checks the VAP to put the beacon frame buffer back to the ATH object
428 * queue, and de-allocates any wbuf frames that were sent as CAB traffic. 423 * queue, and de-allocates any skbs that were sent as CAB traffic.
429*/ 424*/
430
431void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp) 425void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
432{ 426{
433 if (avp->av_bcbuf != NULL) { 427 if (avp->av_bcbuf != NULL) {
@@ -459,10 +453,7 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
459 * Transmit one or more beacon frames at SWBA. Dynamic updates to the frame 453 * Transmit one or more beacon frames at SWBA. Dynamic updates to the frame
460 * contents are done as needed and the slot time is also adjusted based on 454 * contents are done as needed and the slot time is also adjusted based on
461 * current state. 455 * current state.
462 *
463 * This tasklet is not scheduled, it's called in ISR context.
464*/ 456*/
465
466void ath9k_beacon_tasklet(unsigned long data) 457void ath9k_beacon_tasklet(unsigned long data)
467{ 458{
468 struct ath_softc *sc = (struct ath_softc *)data; 459 struct ath_softc *sc = (struct ath_softc *)data;
@@ -490,6 +481,8 @@ void ath9k_beacon_tasklet(unsigned long data)
490 * and wait for the next. Missed beacons indicate 481 * and wait for the next. Missed beacons indicate
491 * a problem and should not occur. If we miss too 482 * a problem and should not occur. If we miss too
492 * many consecutive beacons reset the device. 483 * many consecutive beacons reset the device.
484 *
485 * FIXME: Clean up this mess !!
493 */ 486 */
494 if (ath9k_hw_numtxpending(ah, sc->sc_bhalq) != 0) { 487 if (ath9k_hw_numtxpending(ah, sc->sc_bhalq) != 0) {
495 sc->sc_bmisscount++; 488 sc->sc_bmisscount++;
@@ -505,19 +498,16 @@ void ath9k_beacon_tasklet(unsigned long data)
505 __func__, sc->sc_bmisscount); 498 __func__, sc->sc_bmisscount);
506 if (show_cycles) { 499 if (show_cycles) {
507 /* 500 /*
508 * Display cycle counter stats 501 * Display cycle counter stats from HW
509 * from HW to aide in debug of 502 * to aide in debug of stickiness.
510 * stickiness.
511 */ 503 */
512 DPRINTF(sc, 504 DPRINTF(sc, ATH_DBG_BEACON,
513 ATH_DBG_BEACON,
514 "%s: busy times: rx_clear=%d, " 505 "%s: busy times: rx_clear=%d, "
515 "rx_frame=%d, tx_frame=%d\n", 506 "rx_frame=%d, tx_frame=%d\n",
516 __func__, rx_clear, rx_frame, 507 __func__, rx_clear, rx_frame,
517 tx_frame); 508 tx_frame);
518 } else { 509 } else {
519 DPRINTF(sc, 510 DPRINTF(sc, ATH_DBG_BEACON,
520 ATH_DBG_BEACON,
521 "%s: unable to obtain " 511 "%s: unable to obtain "
522 "busy times\n", __func__); 512 "busy times\n", __func__);
523 } 513 }
@@ -529,8 +519,7 @@ void ath9k_beacon_tasklet(unsigned long data)
529 } else if (sc->sc_bmisscount >= BSTUCK_THRESH) { 519 } else if (sc->sc_bmisscount >= BSTUCK_THRESH) {
530 if (sc->sc_flags & SC_OP_NO_RESET) { 520 if (sc->sc_flags & SC_OP_NO_RESET) {
531 if (sc->sc_bmisscount == BSTUCK_THRESH) { 521 if (sc->sc_bmisscount == BSTUCK_THRESH) {
532 DPRINTF(sc, 522 DPRINTF(sc, ATH_DBG_BEACON,
533 ATH_DBG_BEACON,
534 "%s: beacon is officially " 523 "%s: beacon is officially "
535 "stuck\n", __func__); 524 "stuck\n", __func__);
536 ath9k_hw_dmaRegDump(ah); 525 ath9k_hw_dmaRegDump(ah);
@@ -542,13 +531,12 @@ void ath9k_beacon_tasklet(unsigned long data)
542 ath_bstuck_process(sc); 531 ath_bstuck_process(sc);
543 } 532 }
544 } 533 }
545
546 return; 534 return;
547 } 535 }
536
548 if (sc->sc_bmisscount != 0) { 537 if (sc->sc_bmisscount != 0) {
549 if (sc->sc_flags & SC_OP_NO_RESET) { 538 if (sc->sc_flags & SC_OP_NO_RESET) {
550 DPRINTF(sc, 539 DPRINTF(sc, ATH_DBG_BEACON,
551 ATH_DBG_BEACON,
552 "%s: resume beacon xmit after %u misses\n", 540 "%s: resume beacon xmit after %u misses\n",
553 __func__, sc->sc_bmisscount); 541 __func__, sc->sc_bmisscount);
554 } else { 542 } else {
@@ -572,10 +560,12 @@ void ath9k_beacon_tasklet(unsigned long data)
572 tsftu = TSF_TO_TU(tsf>>32, tsf); 560 tsftu = TSF_TO_TU(tsf>>32, tsf);
573 slot = ((tsftu % intval) * ATH_BCBUF) / intval; 561 slot = ((tsftu % intval) * ATH_BCBUF) / intval;
574 if_id = sc->sc_bslot[(slot + 1) % ATH_BCBUF]; 562 if_id = sc->sc_bslot[(slot + 1) % ATH_BCBUF];
563
575 DPRINTF(sc, ATH_DBG_BEACON, 564 DPRINTF(sc, ATH_DBG_BEACON,
576 "%s: slot %d [tsf %llu tsftu %u intval %u] if_id %d\n", 565 "%s: slot %d [tsf %llu tsftu %u intval %u] if_id %d\n",
577 __func__, slot, (unsigned long long) tsf, tsftu, 566 __func__, slot, (unsigned long long)tsf, tsftu,
578 intval, if_id); 567 intval, if_id);
568
579 bfaddr = 0; 569 bfaddr = 0;
580 if (if_id != ATH_IF_ID_ANY) { 570 if (if_id != ATH_IF_ID_ANY) {
581 bf = ath_beacon_generate(sc, if_id); 571 bf = ath_beacon_generate(sc, if_id);
@@ -632,9 +622,8 @@ void ath9k_beacon_tasklet(unsigned long data)
632 * Tasklet for Beacon Stuck processing 622 * Tasklet for Beacon Stuck processing
633 * 623 *
634 * Processing for Beacon Stuck. 624 * Processing for Beacon Stuck.
635 * Basically calls the ath_internal_reset function to reset the chip. 625 * Basically resets the chip.
636*/ 626*/
637
638void ath_bstuck_process(struct ath_softc *sc) 627void ath_bstuck_process(struct ath_softc *sc)
639{ 628{
640 DPRINTF(sc, ATH_DBG_BEACON, 629 DPRINTF(sc, ATH_DBG_BEACON,
@@ -658,13 +647,12 @@ void ath_bstuck_process(struct ath_softc *sc)
658 * interrupt when we stop seeing beacons from the AP 647 * interrupt when we stop seeing beacons from the AP
659 * we've associated with. 648 * we've associated with.
660 */ 649 */
661
662void ath_beacon_config(struct ath_softc *sc, int if_id) 650void ath_beacon_config(struct ath_softc *sc, int if_id)
663{ 651{
664 struct ath_hal *ah = sc->sc_ah; 652 struct ath_hal *ah = sc->sc_ah;
665 u32 nexttbtt, intval;
666 struct ath_beacon_config conf; 653 struct ath_beacon_config conf;
667 enum ath9k_opmode av_opmode; 654 enum ath9k_opmode av_opmode;
655 u32 nexttbtt, intval;
668 656
669 if (if_id != ATH_IF_ID_ANY) 657 if (if_id != ATH_IF_ID_ANY)
670 av_opmode = sc->sc_vaps[if_id]->av_opmode; 658 av_opmode = sc->sc_vaps[if_id]->av_opmode;
@@ -673,12 +661,6 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
673 661
674 memzero(&conf, sizeof(struct ath_beacon_config)); 662 memzero(&conf, sizeof(struct ath_beacon_config));
675 663
676 /* FIXME: Use default values for now - Sujith */
677 /* Query beacon configuration first */
678 /*
679 * Protocol stack doesn't support dynamic beacon configuration,
680 * use default configurations.
681 */
682 conf.beacon_interval = sc->hw->conf.beacon_int ? 664 conf.beacon_interval = sc->hw->conf.beacon_int ?
683 sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL; 665 sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL;
684 conf.listen_interval = 1; 666 conf.listen_interval = 1;
@@ -704,12 +686,14 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
704 intval = conf.beacon_interval & ATH9K_BEACON_PERIOD; 686 intval = conf.beacon_interval & ATH9K_BEACON_PERIOD;
705 } 687 }
706 688
707 if (nexttbtt == 0) /* e.g. for ap mode */ 689 if (nexttbtt == 0) /* e.g. for ap mode */
708 nexttbtt = intval; 690 nexttbtt = intval;
709 else if (intval) /* NB: can be 0 for monitor mode */ 691 else if (intval) /* NB: can be 0 for monitor mode */
710 nexttbtt = roundup(nexttbtt, intval); 692 nexttbtt = roundup(nexttbtt, intval);
693
711 DPRINTF(sc, ATH_DBG_BEACON, "%s: nexttbtt %u intval %u (%u)\n", 694 DPRINTF(sc, ATH_DBG_BEACON, "%s: nexttbtt %u intval %u (%u)\n",
712 __func__, nexttbtt, intval, conf.beacon_interval); 695 __func__, nexttbtt, intval, conf.beacon_interval);
696
713 /* Check for ATH9K_M_HOSTAP and sc_nostabeacons for WDS client */ 697 /* Check for ATH9K_M_HOSTAP and sc_nostabeacons for WDS client */
714 if (sc->sc_ah->ah_opmode == ATH9K_M_STA) { 698 if (sc->sc_ah->ah_opmode == ATH9K_M_STA) {
715 struct ath9k_beacon_state bs; 699 struct ath9k_beacon_state bs;
@@ -723,19 +707,19 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
723 * last beacon we received (which may be none). 707 * last beacon we received (which may be none).
724 */ 708 */
725 dtimperiod = conf.dtim_period; 709 dtimperiod = conf.dtim_period;
726 if (dtimperiod <= 0) /* NB: 0 if not known */ 710 if (dtimperiod <= 0) /* NB: 0 if not known */
727 dtimperiod = 1; 711 dtimperiod = 1;
728 dtimcount = conf.dtim_count; 712 dtimcount = conf.dtim_count;
729 if (dtimcount >= dtimperiod) /* NB: sanity check */ 713 if (dtimcount >= dtimperiod) /* NB: sanity check */
730 dtimcount = 0; /* XXX? */ 714 dtimcount = 0;
731 cfpperiod = 1; /* NB: no PCF support yet */ 715 cfpperiod = 1; /* NB: no PCF support yet */
732 cfpcount = 0; 716 cfpcount = 0;
733 717
734 sleepduration = conf.listen_interval * intval; 718 sleepduration = conf.listen_interval * intval;
735 if (sleepduration <= 0) 719 if (sleepduration <= 0)
736 sleepduration = intval; 720 sleepduration = intval;
737 721
738#define FUDGE 2 722#define FUDGE 2
739 /* 723 /*
740 * Pull nexttbtt forward to reflect the current 724 * Pull nexttbtt forward to reflect the current
741 * TSF and calculate dtim+cfp state for the result. 725 * TSF and calculate dtim+cfp state for the result.
@@ -759,6 +743,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
759 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod; 743 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod;
760 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod; 744 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod;
761 bs.bs_cfpmaxduration = 0; 745 bs.bs_cfpmaxduration = 0;
746
762 /* 747 /*
763 * Calculate the number of consecutive beacons to miss 748 * Calculate the number of consecutive beacons to miss
764 * before taking a BMISS interrupt. The configuration 749 * before taking a BMISS interrupt. The configuration
@@ -767,9 +752,8 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
767 * result to at most 15 beacons. 752 * result to at most 15 beacons.
768 */ 753 */
769 if (sleepduration > intval) { 754 if (sleepduration > intval) {
770 bs.bs_bmissthreshold = 755 bs.bs_bmissthreshold = conf.listen_interval *
771 conf.listen_interval * 756 ATH_DEFAULT_BMISS_LIMIT / 2;
772 ATH_DEFAULT_BMISS_LIMIT / 2;
773 } else { 757 } else {
774 bs.bs_bmissthreshold = 758 bs.bs_bmissthreshold =
775 DIV_ROUND_UP(conf.bmiss_timeout, intval); 759 DIV_ROUND_UP(conf.bmiss_timeout, intval);
@@ -789,8 +773,8 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
789 * XXX fixed at 100ms 773 * XXX fixed at 100ms
790 */ 774 */
791 775
792 bs.bs_sleepduration = 776 bs.bs_sleepduration = roundup(IEEE80211_MS_TO_TU(100),
793 roundup(IEEE80211_MS_TO_TU(100), sleepduration); 777 sleepduration);
794 if (bs.bs_sleepduration > bs.bs_dtimperiod) 778 if (bs.bs_sleepduration > bs.bs_dtimperiod)
795 bs.bs_sleepduration = bs.bs_dtimperiod; 779 bs.bs_sleepduration = bs.bs_dtimperiod;
796 780
@@ -834,9 +818,9 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
834 if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS) { 818 if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS) {
835 /* 819 /*
836 * Pull nexttbtt forward to reflect the current 820 * Pull nexttbtt forward to reflect the current
837 * TSF . 821 * TSF
838 */ 822 */
839#define FUDGE 2 823#define FUDGE 2
840 if (!(intval & ATH9K_BEACON_RESET_TSF)) { 824 if (!(intval & ATH9K_BEACON_RESET_TSF)) {
841 tsf = ath9k_hw_gettsf64(ah); 825 tsf = ath9k_hw_gettsf64(ah);
842 tsftu = TSF_TO_TU((u32)(tsf>>32), 826 tsftu = TSF_TO_TU((u32)(tsf>>32),