Optimize and clean TX time computation.

Avoid a test and a modulus operation.

MFC after:	2 weeks
This commit is contained in:
Damien Bergamini 2005-11-15 17:17:15 +00:00
parent 878124fed4
commit 43b60fd47d
2 changed files with 14 additions and 44 deletions

View File

@ -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;

View File

@ -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;