Documentation/cImages/baseline-2.3.ndz: patch-02-adhoc-beacon-6.diff
File patch-02-adhoc-beacon-6.diff, 6.1 KB (added by , 17 years ago) |
---|
-
madwifi-0.9.3.
Ad-hoc mode beacons are not transmitted for a while after a merge with another network. http://madwifi.org/ticket/1033 This patch was rebased for madwifi-0.9.3.1 Signed-Off by: Luis Rodriguez <mcgrof@winlab.rutgers.edu> diff -Naur madwifi-0.9.3.1/ath/if_ath.c madwifi-0.9.3.1-adhoc-beacon5/ath/if_ath.c
old new 4420 4420 struct ieee80211com *ic = &sc->sc_ic; 4421 4421 struct ath_hal *ah = sc->sc_ah; 4422 4422 struct ieee80211_node *ni; 4423 u_int32_t nexttbtt, intval; 4423 u_int32_t nexttbtt = 0; 4424 u_int32_t intval; 4425 u_int64_t tsf, hw_tsf; 4426 u_int32_t tsftu, hw_tsftu; 4427 int should_reset_tsf = 0; 4424 4428 4425 4429 if (vap == NULL) 4426 4430 vap = TAILQ_FIRST(&ic->ic_vaps); /* XXX */ 4427 4431 4428 4432 ni = vap->iv_bss; 4429 4433 4430 /* extract tstamp from last beacon and convert to TU */ 4431 nexttbtt = TSF_TO_TU(LE_READ_4(ni->ni_tstamp.data + 4), 4432 LE_READ_4(ni->ni_tstamp.data)); 4434 hw_tsf = ath_hal_gettsf64(ah); 4435 tsf = le64_to_cpu(ni->ni_tstamp.tsf); 4436 hw_tsftu = hw_tsf >> 10; 4437 tsftu = tsf >> 10; 4438 4439 /* we should reset hw TSF only once, so we increment 4440 ni_tstamp.tsf to avoid resetting the hw TSF multiple 4441 times */ 4442 4443 if (tsf == 0) { 4444 should_reset_tsf = 1; 4445 ni->ni_tstamp.tsf = cpu_to_le64(1); 4446 } 4447 4433 4448 /* XXX conditionalize multi-bss support? */ 4434 4449 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 4435 4450 /* … … 4443 4458 if (sc->sc_stagbeacons) 4444 4459 intval /= ATH_BCBUF; /* for staggered beacons */ 4445 4460 if ((sc->sc_nostabeacons) && 4446 4447 nexttbtt = 0;4461 (vap->iv_opmode == IEEE80211_M_HOSTAP)) 4462 should_reset_tsf = 1; 4448 4463 } else 4449 4464 intval = ni->ni_intval & HAL_BEACON_PERIOD; 4450 if (nexttbtt == 0) /* e.g. for ap mode */ 4465 4466 #define FUDGE 2 4467 sc->sc_syncbeacon = 0; 4468 if (should_reset_tsf) { 4469 4470 /* We just created the interface and TSF will be reset to 4471 zero, so next beacon will be sent at the next intval 4472 time */ 4473 4451 4474 nexttbtt = intval; 4452 else if (intval) /* NB: can be 0 for monitor mode */ 4453 nexttbtt = roundup(nexttbtt, intval); 4454 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt %u intval %u (%u)\n", 4455 __func__, nexttbtt, intval, ni->ni_intval); 4475 } else if (intval) { /* NB: can be 0 for monitor mode */ 4476 if (tsf == 1) { 4477 4478 /* We do not receive any beacons or probe response. Since 4479 a beacon should be sent every 'intval' ms, we compute 4480 the next beacon timestamp using the hardware TSF. We 4481 ensure that it is at least FUDGE ms ahead of the 4482 current TSF. Otherwise, we use the next beacon 4483 timestamp again */ 4484 4485 nexttbtt = roundup(hw_tsftu +1, intval); 4486 while (nexttbtt <= hw_tsftu + FUDGE) { 4487 nexttbtt += intval; 4488 } 4489 } else { 4490 if (tsf > hw_tsf) { 4491 4492 /* We do receive a beacon from someone else in the past, 4493 but the hw TSF has not been updated (otherwise we 4494 would have tsf >= hw_tsf). Since we cannot use the 4495 hardware TSF, we will do nothing and wait for the 4496 next beacon. In order to do so, we set sc->syncbeacon 4497 again */ 4498 4499 sc->sc_syncbeacon = 1; 4500 goto ath_beacon_config_debug; 4501 } else { 4502 /* We do receive a beacon in the past, normal case. We 4503 make sure that the timestamp is at least FUDGE ms 4504 ahead of the hardware TSF */ 4505 4506 nexttbtt = tsftu + intval; 4507 while (nexttbtt <= hw_tsftu + FUDGE) { 4508 nexttbtt += intval; 4509 } 4510 } 4511 } 4512 } 4513 4456 4514 if (ic->ic_opmode == IEEE80211_M_STA && !(sc->sc_nostabeacons)) { 4457 4515 HAL_BEACON_STATE bs; 4458 u_int64_t tsf;4459 u_int32_t tsftu;4460 4516 int dtimperiod, dtimcount; 4461 4517 int cfpperiod, cfpcount; 4462 4518 … … 4472 4528 dtimcount = 0; /* XXX? */ 4473 4529 cfpperiod = 1; /* NB: no PCF support yet */ 4474 4530 cfpcount = 0; 4475 #define FUDGE 24476 4531 /* 4477 4532 * Pull nexttbtt forward to reflect the current 4478 4533 * TSF and calculate dtim+cfp state for the result. 4479 4534 */ 4480 tsf = ath_hal_gettsf64(ah); 4481 tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; 4535 nexttbtt = tsftu; 4536 if (nexttbtt == 0) /* e.g. for ap mode */ 4537 nexttbtt = intval; 4482 4538 do { 4483 4539 nexttbtt += intval; 4484 4540 if (--dtimcount < 0) { … … 4486 4542 if (--cfpcount < 0) 4487 4543 cfpcount = cfpperiod - 1; 4488 4544 } 4489 } while (nexttbtt < tsftu);4545 } while (nexttbtt < hw_tsftu + FUDGE); 4490 4546 #undef FUDGE 4491 4547 memset(&bs, 0, sizeof(bs)); 4492 4548 bs.bs_intval = intval; … … 4538 4594 DPRINTF(sc, ATH_DEBUG_BEACON, 4539 4595 "%s: tsf %llu tsf:tu %u intval %u nexttbtt %u dtim %u nextdtim %u bmiss %u sleep %u cfp:period %u maxdur %u next %u timoffset %u\n" 4540 4596 , __func__ 4541 , (long long) tsf,tsftu4597 , (long long) hw_tsf, hw_tsftu 4542 4598 , bs.bs_intval 4543 4599 , bs.bs_nexttbtt 4544 4600 , bs.bs_dtimperiod … … 4557 4613 ath_hal_intrset(ah, sc->sc_imask); 4558 4614 } else { 4559 4615 ath_hal_intrset(ah, 0); 4560 if ( nexttbtt == intval)4616 if (should_reset_tsf) 4561 4617 intval |= HAL_BEACON_RESET_TSF; 4562 4618 if (ic->ic_opmode == IEEE80211_M_IBSS) { 4563 4619 /* … … 4594 4650 if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol) 4595 4651 ath_beacon_start_adhoc(sc, vap); 4596 4652 } 4597 sc->sc_syncbeacon = 0;4598 4653 #undef TSF_TO_TU 4654 4655 ath_beacon_config_debug: 4656 4657 /* we print all debug messages here, in order to preserve the 4658 time critical aspect of this function */ 4659 4660 DPRINTF(sc, ATH_DEBUG_BEACON, 4661 "%s: ni=%p tsf=%llu hw_tsf=%llu tsftu=%u hw_tsftu=%u\n", 4662 __func__, ni, tsf, hw_tsf, tsftu, hw_tsftu); 4663 4664 if (should_reset_tsf) { 4665 /* we just created the interface */ 4666 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: first beacon\n",__func__); 4667 } else { 4668 if (tsf == 1) { 4669 /* we do not receive any beacons or probe response */ 4670 DPRINTF(sc, ATH_DEBUG_BEACON, 4671 "%s: no beacon received...\n",__func__); 4672 } else { 4673 if (tsf > hw_tsf) { 4674 /* we do receive a beacon and the hw TSF has not been updated */ 4675 DPRINTF(sc, ATH_DEBUG_BEACON, 4676 "%s: beacon received, but TSF is incorrect\n",__func__); 4677 } else { 4678 /* we do receive a beacon in the past, normal case */ 4679 DPRINTF(sc, ATH_DEBUG_BEACON, 4680 "%s: beacon received, TSF is correct\n",__func__); 4681 } 4682 } 4683 } 4684 4685 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt=%u intval=%u\n", 4686 __func__,nexttbtt, intval & HAL_BEACON_PERIOD); 4599 4687 } 4600 4688 4601 4689 static int