Distance/slot time & ack. timeout configuration:

* Update comments and references
* Refactor slot time from distance calculation code
* Correct timeout calculation (i.e., remove incorrect factor of 2)


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3753 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
mentor 2008-07-06 01:44:44 +00:00
parent 2dc12013f6
commit 3b5b743774

View File

@ -4241,21 +4241,23 @@ ath_mode_init(struct net_device *dev)
static inline int static inline int
ath_slottime2timeout(struct ath_softc *sc, int slottime) ath_slottime2timeout(struct ath_softc *sc, int slottime)
{ {
/* HAL seems to use a constant of 8 for OFDM overhead and 18 for /* IEEE 802.11 2007 9.2.8 says the ACK timeout shall be SIFSTime +
* CCK overhead. * slot time (+ PHY RX start delay). HAL seems to use a constant of 8
* for OFDM overhead and 18 for CCK overhead.
* *
* XXX: Update based on emperical evidence (potentially save 15us per timeout) * XXX: Update based on emperical evidence (potentially save 15us per
*/ * timeout). */
if (((sc->sc_curchan.channelFlags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A) || if (((sc->sc_curchan.channelFlags & IEEE80211_CHAN_A) ==
(((sc->sc_curchan.channelFlags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G) && IEEE80211_CHAN_A) ||
(((sc->sc_curchan.channelFlags & IEEE80211_CHAN_108G) ==
IEEE80211_CHAN_108G) &&
(sc->sc_ic.ic_flags & IEEE80211_F_SHSLOT))) (sc->sc_ic.ic_flags & IEEE80211_F_SHSLOT)))
{ /* Short slot time: 802.11a, and 802.11g turbo in turbo mode
/* short slot time - 802.11a, and 802.11g turbo in turbo mode with short slot time */ * with short slot time. */
return (slottime * 2) + 8; return slottime + 8;
} else
/* Constant for CCK MIB processing time. */
/* constant for CCK mib processing time */ return slottime + 18;
return (slottime * 2) + 18;
} }
#ifndef MAX #ifndef MAX
@ -10453,48 +10455,44 @@ ath_ccatime(struct ath_softc *sc)
static inline int static inline int
ath_estimate_max_distance(struct ath_softc *sc) ath_estimate_max_distance(struct ath_softc *sc)
{ {
/* Prefer overrided, ask HAL if not overridden */ /* Prefer override; ask HAL if not overridden. */
int slottime = sc->sc_slottimeconf; int slottime = sc->sc_slottimeconf;
if (slottime <= 0) if (slottime <= 0)
slottime = ath_hal_getslottime(sc->sc_ah); slottime = ath_hal_getslottime(sc->sc_ah);
/* NB: We ignore MAC overhead. this function is reverse operation of /* NB: We ignore MAC overhead. This function is the reverse operation
* ath_distance2slottime, and assumes slottime is CCA + 2x air propagation. */ * of ath_distance2slottime, and assumes slottime is CCA + 2 * air
* propagation. */
return (slottime - ath_ccatime(sc)) * 150; return (slottime - ath_ccatime(sc)) * 150;
} }
static inline int static inline int
ath_distance2slottime(struct ath_softc *sc, int distance) ath_distance2slottime(struct ath_softc *sc, int distance)
{ {
/* Allowance for air propagation (roundtrip time) should be at least /* Allowance for air propagation (roundtrip time) should be at least
* 5us per the standards. * 5us per the standards.
* *
* So let's set a minimum distance to accomodate this: * So let's set a minimum distance to accomodate this:
*
* roundtrip time = ((distance / speed_of_light) * 2) * roundtrip time = ((distance / speed_of_light) * 2)
* * distance = ((time * 300 ) / 2) or ((5 * 300) / 2) = 750 m */
* distance = ( (time * 300 ) / 2) or ((5 * 300) / 2) = 750 m
*/
int rtdist = distance * 2; int rtdist = distance * 2;
int aAirPropagation = (rtdist / 300) + !!(rtdist % 300); int c = 299; /* Speed of light in vacuum in m/us. */
if (aAirPropagation < 5) { /* IEEE 802.11 2007 10l.4.3.2. In us. */
aAirPropagation = 5; int aAirPropagation = MAX(5, howmany(rtdist, c));
} /* XXX: RX/TX turnaround & MAC delay. */
/* NB: We ignore MAC processing delays... no clue */
return ath_ccatime(sc) + aAirPropagation; return ath_ccatime(sc) + aAirPropagation;
} }
static inline int static inline int
ath_distance2timeout(struct ath_softc *sc, int distance) ath_distance2timeout(struct ath_softc *sc, int distance)
{ {
/* HAL uses a constant of twice slot time plus 18us. /* HAL uses a constant of twice slot time plus 18us. The 18us covers
* The 18us covers rxtx turnaround, MIB processing, etc. * RX/TX turnaround, MIB processing, etc., but the athctrl used to
* but the athctrl used to return 2slot+3 so the extra 15us of * return (2 * slot) + 3, so the extra 15us of timeout is probably just
* timeout is probably just being very careful or taking something into * being very careful or taking something into account that I can't
* account that I can't find in the specs. * find in the specs.
* *
* XXX: Update based on emperical evidence (potentially save 15us per timeout) * XXX: Update based on emperical evidence (potentially save 15us per
*/ * timeout). */
return ath_slottime2timeout(sc, ath_distance2slottime(sc, distance)); return ath_slottime2timeout(sc, ath_distance2slottime(sc, distance));
} }
@ -10510,10 +10508,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
ctl->data = &val; ctl->data = &val;
ctl->maxlen = sizeof(val); ctl->maxlen = sizeof(val);
/* special case for ATH_RP which expect 3 integers : tsf rssi /* Special case for ATH_RP which expect 3 integers: TSF RSSI width. It
* width. It should be noted that tsf is unsigned 64 bits but the * should be noted that tsf is unsigned 64 bits but the sysctl API is
* sysctl API is only unsigned 32 bits. As a result, tsf might get * only unsigned 32 bits. As a result, TSF might get truncated. */
* truncated */
if (ctl->extra2 == (void *)ATH_RP) { if (ctl->extra2 == (void *)ATH_RP) {
ctl->data = &tab_3_val; ctl->data = &tab_3_val;
ctl->maxlen = sizeof(tab_3_val); ctl->maxlen = sizeof(tab_3_val);