From owner-p4-projects@FreeBSD.ORG Mon Jan 14 04:41:25 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1542B16A420; Mon, 14 Jan 2008 04:41:25 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CEB4716A41B for ; Mon, 14 Jan 2008 04:41:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CA77E13C4EC for ; Mon, 14 Jan 2008 04:41:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0E4fOXe020779 for ; Mon, 14 Jan 2008 04:41:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0E4fO4R020776 for perforce@freebsd.org; Mon, 14 Jan 2008 04:41:24 GMT (envelope-from sephe@FreeBSD.org) Date: Mon, 14 Jan 2008 04:41:24 GMT Message-Id: <200801140441.m0E4fO4R020776@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau To: Perforce Change Reviews Cc: Subject: PERFORCE change 133223 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2008 04:41:25 -0000 http://perforce.freebsd.org/chv.cgi?CH=133223 Change 133223 by sephe@sephe_zealot:sam_wifi on 2008/01/14 04:40:41 - Compute durations for nonfrag data frames - Rename controlRate to ctlRateIndex - Indentation - Adjust comments a little bit - Don't map for short preamble rates, this kind of mapping does not work (0x04 overlap some rate codes) and it is never used - Rename ieee80211_compute_txtime to ieee80211_compute_duration, since the result returned by this function includes SIFS Affected files ... .. //depot/projects/wifi/sys/net80211/ieee80211_phy.c#3 edit Differences ... ==== //depot/projects/wifi/sys/net80211/ieee80211_phy.c#3 (text+ko) ==== @@ -89,7 +89,7 @@ * preamble in CCK rate code */ uint8_t dot11Rate; /* value for supported rates * info element of MLME */ - uint8_t controlRate; /* index of next lower basic + uint8_t ctlRateIndex; /* index of next lower basic * rate; used for dur. calcs */ uint16_t lpAckDuration; /* long preamble ACK dur. */ uint16_t spAckDuration; /* short preamble ACK dur. */ @@ -102,8 +102,6 @@ const struct ieee80211_rate_table *, uint8_t rate); uint8_t ieee80211_ack_rate(const struct ieee80211_rate_table *, uint8_t rate); -uint16_t ieee80211_compute_txtime(const struct ieee80211_rate_table *, - uint32_t frameLen, uint16_t rate, int flags); #endif /* notyet */ /* shorthands to compact tables for readability */ @@ -113,7 +111,7 @@ #define PBCC (IEEE80211_T_HT+1) /* XXX */ static struct ieee80211_rate_table ieee80211_11b_table = { - 4, /* number of rates */ + 4, /* number of rates, XXX no PBCC */ { 0 }, { /* short ctrl */ @@ -238,6 +236,8 @@ #undef XR static void ieee80211_setup_ratetable(struct ieee80211_rate_table *); +static uint16_t ieee80211_compute_duration(const struct ieee80211_rate_table *, + uint32_t frameLen, uint16_t rate, int flags); /* Setup all rate tables */ void @@ -278,41 +278,38 @@ ieee80211_setup_ratetable(struct ieee80211_rate_table *rt) { #define N(a) (sizeof(a)/sizeof(a[0])) -#define WLAN_CTRL_FRAME_SIZE (2+2+6+4) /* ACK+FCS */ +#define WLAN_CTRL_FRAME_SIZE \ + (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) + int i; for (i = 0; i < N(rt->rateCodeToIndex); i++) rt->rateCodeToIndex[i] = (uint8_t) -1; for (i = 0; i < rt->rateCount; i++) { uint8_t code = rt->info[i].dot11Rate; -#ifdef notyet - uint8_t cix = rt->info[i].controlRate; -#endif + uint8_t cix = rt->info[i].ctlRateIndex; rt->rateCodeToIndex[code] = i; - rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i; if (code & IEEE80211_RATE_BASIC) { /* * Map w/o basic rate bit too. */ code &= IEEE80211_RATE_VAL; rt->rateCodeToIndex[code] = i; - rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i; } -#ifdef notyet /* * XXX for 11g the control rate to use for 5.5 and 11 Mb/s * depends on whether they are marked as basic rates; * the static tables are setup with an 11b-compatible * 2Mb/s rate which will work but is suboptimal */ - rt->info[i].lpAckDuration = ieee80211_compute_txtime(rt, + rt->info[i].lpAckDuration = ieee80211_compute_duration(rt, WLAN_CTRL_FRAME_SIZE, cix, 0); - rt->info[i].spAckDuration = ieee80211_compute_txtime(rt, - WLAN_CTRL_FRAME_SIZE, cix, 1); -#endif /* notyet */ + rt->info[i].spAckDuration = ieee80211_compute_duration(rt, + WLAN_CTRL_FRAME_SIZE, cix, IEEE80211_F_SHPREAMBLE); } + #undef WLAN_CTRL_FRAME_SIZE #undef N } @@ -401,16 +398,19 @@ uint8_t ieee80211_ack_rate(const struct ieee80211_rate_table *rt, uint8_t rate) { - uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].controlRate; + uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex; return rt->info[cix].dot11Rate; } +#endif /* notyet */ + /* * Compute the time to transmit a frame of length frameLen bytes * using the specified rate, phy, and short preamble setting. + * SIFS is included. */ -uint16_t -ieee80211_compute_txtime(const struct ieee80211_rate_table *rt, +static uint16_t +ieee80211_compute_duration(const struct ieee80211_rate_table *rt, uint32_t frameLen, uint16_t rate, int flags) { uint8_t rix = rt->rateCodeToIndex[rate]; @@ -424,9 +424,9 @@ switch (rt->info[rix].phy) { case IEEE80211_T_CCK: -#define CCK_SIFS_TIME 10 -#define CCK_PREAMBLE_BITS 144 -#define CCK_PLCP_BITS 48 +#define CCK_SIFS_TIME 10 +#define CCK_PREAMBLE_BITS 144 +#define CCK_PLCP_BITS 48 phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS; if ((flags & IEEE80211_F_SHPREAMBLE) && rt->info[rix].shortPreamble) @@ -440,10 +440,10 @@ #undef CCK_PLCP_BITS case IEEE80211_T_OFDM: -#define OFDM_SIFS_TIME 16 -#define OFDM_PREAMBLE_TIME 20 -#define OFDM_PLCP_BITS 22 -#define OFDM_SYMBOL_TIME 4 +#define OFDM_SIFS_TIME 16 +#define OFDM_PREAMBLE_TIME 20 +#define OFDM_PLCP_BITS 22 +#define OFDM_SYMBOL_TIME 4 #define OFDM_SIFS_TIME_HALF 32 #define OFDM_PREAMBLE_TIME_HALF 40 @@ -461,7 +461,7 @@ numBits = OFDM_PLCP_BITS + (frameLen << 3); numSymbols = howmany(numBits, bitsPerSymbol); txTime = OFDM_SIFS_TIME_QUARTER - + OFDM_PREAMBLE_TIME_QUARTER + + OFDM_PREAMBLE_TIME_QUARTER + (numSymbols * OFDM_SYMBOL_TIME_QUARTER); } else if (rt == &ieee80211_quarter_table) { bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_HALF) / 1000; @@ -469,8 +469,8 @@ numBits = OFDM_PLCP_BITS + (frameLen << 3); numSymbols = howmany(numBits, bitsPerSymbol); - txTime = OFDM_SIFS_TIME_HALF + - OFDM_PREAMBLE_TIME_HALF + txTime = OFDM_SIFS_TIME_HALF + + OFDM_PREAMBLE_TIME_HALF + (numSymbols * OFDM_SYMBOL_TIME_HALF); } else { /* full rate channel */ bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME) / 1000; @@ -478,7 +478,8 @@ numBits = OFDM_PLCP_BITS + (frameLen << 3); numSymbols = howmany(numBits, bitsPerSymbol); - txTime = OFDM_SIFS_TIME + OFDM_PREAMBLE_TIME + txTime = OFDM_SIFS_TIME + + OFDM_PREAMBLE_TIME + (numSymbols * OFDM_SYMBOL_TIME); } break; @@ -489,10 +490,10 @@ #undef OFDM_SYMBOL_TIME case IEEE80211_T_TURBO: -#define TURBO_SIFS_TIME 8 -#define TURBO_PREAMBLE_TIME 14 -#define TURBO_PLCP_BITS 22 -#define TURBO_SYMBOL_TIME 4 +#define TURBO_SIFS_TIME 8 +#define TURBO_PREAMBLE_TIME 14 +#define TURBO_PLCP_BITS 22 +#define TURBO_SYMBOL_TIME 4 /* we still save OFDM rates in kbps - so double them */ bitsPerSymbol = ((kbps << 1) * TURBO_SYMBOL_TIME) / 1000; KASSERT(bitsPerSymbol != 0, ("turbo bps")); @@ -508,12 +509,9 @@ #undef TURBO_SYMBOL_TIME default: - printf("%s: unknown phy %u (rate %u)\n", - __func__, rt->info[rix].phy, rate); - txTime = 0; + panic("%s: unknown phy %u (rate %u)\n", __func__, + rt->info[rix].phy, rate); break; } return txTime; } - -#endif /* notyet */