summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordamien <damien@FreeBSD.org>2005-11-15 17:17:15 +0000
committerdamien <damien@FreeBSD.org>2005-11-15 17:17:15 +0000
commitc5a63d4930261dcf56d27baa488b7fb86d25145d (patch)
tree42a10684a8dcbb723e502887450a81a7a14fb349
parent4d0bac87fc56808998c605a342222b4ae15e0710 (diff)
downloadFreeBSD-src-c5a63d4930261dcf56d27baa488b7fb86d25145d.zip
FreeBSD-src-c5a63d4930261dcf56d27baa488b7fb86d25145d.tar.gz
Optimize and clean TX time computation.
Avoid a test and a modulus operation. MFC after: 2 weeks
-rw-r--r--sys/dev/ral/if_ral.c29
-rw-r--r--sys/dev/usb/if_ural.c29
2 files changed, 14 insertions, 44 deletions
diff --git a/sys/dev/ral/if_ral.c b/sys/dev/ral/if_ral.c
index 79cbd05..86e74a0 100644
--- a/sys/dev/ral/if_ral.c
+++ b/sys/dev/ral/if_ral.c
@@ -1624,33 +1624,18 @@ static uint16_t
ral_txtime(int len, int rate, uint32_t flags)
{
uint16_t txtime;
- int ceil, dbps;
if (RAL_RATE_IS_OFDM(rate)) {
- /*
- * OFDM TXTIME calculation.
- * From IEEE Std 802.11a-1999, pp. 37.
- */
- dbps = rate * 2; /* data bits per OFDM symbol */
-
- ceil = (16 + 8 * len + 6) / dbps;
- if ((16 + 8 * len + 6) % dbps != 0)
- ceil++;
-
- txtime = 16 + 4 + 4 * ceil + 6;
+ /* IEEE Std 802.11a-1999, pp. 37 */
+ txtime = (8 + 4 * len + 3 + rate - 1) / rate;
+ txtime = 16 + 4 + 4 * txtime + 6;
} else {
- /*
- * High Rate TXTIME calculation.
- * From IEEE Std 802.11b-1999, pp. 28.
- */
- ceil = (8 * len * 2) / rate;
- if ((8 * len * 2) % rate != 0)
- ceil++;
-
+ /* IEEE Std 802.11b-1999, pp. 28 */
+ txtime = (16 * len + rate - 1) / rate;
if (rate != 2 && (flags & IEEE80211_F_SHPREAMBLE))
- txtime = 72 + 24 + ceil;
+ txtime += 72 + 24;
else
- txtime = 144 + 48 + ceil;
+ txtime += 144 + 48;
}
return txtime;
diff --git a/sys/dev/usb/if_ural.c b/sys/dev/usb/if_ural.c
index 92d103a..2e5f38b 100644
--- a/sys/dev/usb/if_ural.c
+++ b/sys/dev/usb/if_ural.c
@@ -955,33 +955,18 @@ Static uint16_t
ural_txtime(int len, int rate, uint32_t flags)
{
uint16_t txtime;
- int ceil, dbps;
if (RAL_RATE_IS_OFDM(rate)) {
- /*
- * OFDM TXTIME calculation.
- * From IEEE Std 802.11a-1999, pp. 37.
- */
- dbps = rate * 2; /* data bits per OFDM symbol */
-
- ceil = (16 + 8 * len + 6) / dbps;
- if ((16 + 8 * len + 6) % dbps != 0)
- ceil++;
-
- txtime = 16 + 4 + 4 * ceil + 6;
+ /* IEEE Std 802.11a-1999, pp. 37 */
+ txtime = (8 + 4 * len + 3 + rate - 1) / rate;
+ txtime = 16 + 4 + 4 * txtime + 6;
} else {
- /*
- * High Rate TXTIME calculation.
- * From IEEE Std 802.11b-1999, pp. 28.
- */
- ceil = (8 * len * 2) / rate;
- if ((8 * len * 2) % rate != 0)
- ceil++;
-
+ /* IEEE Std 802.11b-1999, pp. 28 */
+ txtime = (16 * len + rate - 1) / rate;
if (rate != 2 && (flags & IEEE80211_F_SHPREAMBLE))
- txtime = 72 + 24 + ceil;
+ txtime += 72 + 24;
else
- txtime = 144 + 48 + ceil;
+ txtime += 144 + 48;
}
return txtime;
OpenPOWER on IntegriCloud