From owner-p4-projects@FreeBSD.ORG Mon Feb 4 07:38:04 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C1ADE16A63B; Mon, 4 Feb 2008 07:38:04 +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 6247516A625 for ; Mon, 4 Feb 2008 07:38:04 +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 4D95213C4D9 for ; Mon, 4 Feb 2008 07:38:04 +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 m147c422033229 for ; Mon, 4 Feb 2008 07:38:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m147c44K033226 for perforce@freebsd.org; Mon, 4 Feb 2008 07:38:04 GMT (envelope-from sephe@FreeBSD.org) Date: Mon, 4 Feb 2008 07:38:04 GMT Message-Id: <200802040738.m147c44K033226@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 134764 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, 04 Feb 2008 07:38:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=134764 Change 134764 by sephe@sephe_zealot:sam_wifi on 2008/02/04 07:37:51 Utilize ieee80211_{ack,compute}_duration() Affected files ... .. //depot/projects/wifi/sys/dev/ral/rt2560.c#31 edit Differences ... ==== //depot/projects/wifi/sys/dev/ral/rt2560.c#31 (text) ==== @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -109,11 +110,9 @@ static void rt2560_beacon_expire(struct rt2560_softc *); static void rt2560_wakeup_expire(struct rt2560_softc *); static uint8_t rt2560_rxrate(struct rt2560_rx_desc *); -static int rt2560_ack_rate(struct ieee80211com *, int); static void rt2560_scan_start(struct ieee80211com *); static void rt2560_scan_end(struct ieee80211com *); static void rt2560_set_channel(struct ieee80211com *); -static uint16_t rt2560_txtime(int, int, uint32_t); static uint8_t rt2560_plcp_signal(int); static void rt2560_setup_tx_desc(struct rt2560_softc *, struct rt2560_tx_desc *, uint32_t, int, int, int, @@ -1401,14 +1400,7 @@ RAL_UNLOCK(sc); } -/* quickly determine if a given rate is CCK or OFDM */ -#define RAL_RATE_IS_OFDM(rate) ((rate) >= 12 && (rate) != 22) - -#define RAL_ACK_SIZE 14 /* 10 + 4(FCS) */ -#define RAL_CTS_SIZE 14 /* 10 + 4(FCS) */ - #define RAL_SIFS 10 /* us */ - #define RT2560_TXRX_TURNAROUND 10 /* us */ /* @@ -1442,66 +1434,6 @@ return 2; /* should not get there */ } -/* - * Return the expected ack rate for a frame transmitted at rate `rate'. - * XXX: this should depend on the destination node basic rate set. - */ -static int -rt2560_ack_rate(struct ieee80211com *ic, int rate) -{ - switch (rate) { - /* CCK rates */ - case 2: - return 2; - case 4: - case 11: - case 22: - return (ic->ic_curmode == IEEE80211_MODE_11B) ? 4 : rate; - - /* OFDM rates */ - case 12: - case 18: - return 12; - case 24: - case 36: - return 24; - case 48: - case 72: - case 96: - case 108: - return 48; - } - - /* default to 1Mbps */ - return 2; -} - -/* - * Compute the duration (in us) needed to transmit `len' bytes at rate `rate'. - * The function automatically determines the operating mode depending on the - * given rate. `flags' indicates whether short preamble is in use or not. - */ -static uint16_t -rt2560_txtime(int len, int rate, uint32_t flags) -{ - uint16_t txtime; - - if (RAL_RATE_IS_OFDM(rate)) { - /* IEEE Std 802.11a-1999, pp. 37 */ - txtime = (8 + 4 * len + 3 + rate - 1) / rate; - txtime = 16 + 4 + 4 * txtime + 6; - } else { - /* IEEE Std 802.11b-1999, pp. 28 */ - txtime = (16 * len + rate - 1) / rate; - if (rate != 2 && (flags & IEEE80211_F_SHPREAMBLE)) - txtime += 72 + 24; - else - txtime += 144 + 48; - } - - return txtime; -} - static uint8_t rt2560_plcp_signal(int rate) { @@ -1549,7 +1481,7 @@ desc->plcp_service = 4; len += IEEE80211_CRC_LEN; - if (RAL_RATE_IS_OFDM(rate)) { + if (ieee80211_rate2phytype(ic->ic_curchan, rate) == IEEE80211_T_OFDM) { desc->flags |= htole32(RT2560_TX_OFDM); plcp_length = len & 0xfff; @@ -1687,8 +1619,8 @@ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2560_TX_ACK; - dur = rt2560_txtime(RAL_ACK_SIZE, rate, ic->ic_flags) + - RAL_SIFS; + dur = ieee80211_ack_duration(ic->ic_curchan, rate, + ic->ic_flags); *(uint16_t *)wh->i_dur = htole16(dur); /* tell hardware to add timestamp for probe responses */ @@ -1868,15 +1800,17 @@ m0->m_pkthdr.len > ic->ic_rtsthreshold) { struct mbuf *m; uint16_t dur; - int rtsrate, ackrate; + int rtsrate; rtsrate = IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan) ? 12 : 2; - ackrate = rt2560_ack_rate(ic, rate); - dur = rt2560_txtime(m0->m_pkthdr.len + 4, rate, ic->ic_flags) + - rt2560_txtime(RAL_CTS_SIZE, rtsrate, ic->ic_flags) + - rt2560_txtime(RAL_ACK_SIZE, ackrate, ic->ic_flags) + - 3 * RAL_SIFS; + dur = ieee80211_ack_duration(ic->ic_curchan, + rtsrate, ic->ic_flags) + + ieee80211_compute_duration(ic->ic_curchan, + m0->m_pkthdr.len + IEEE80211_CRC_LEN, rate, + ic->ic_flags) + + ieee80211_ack_duration(ic->ic_curchan, + rate, ic->ic_flags); m = rt2560_get_rts(sc, wh, dur); @@ -1982,8 +1916,8 @@ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2560_TX_ACK; - dur = rt2560_txtime(RAL_ACK_SIZE, rt2560_ack_rate(ic, rate), - ic->ic_flags) + RAL_SIFS; + dur = ieee80211_ack_duration(ic->ic_curchan, rate, + ic->ic_flags); *(uint16_t *)wh->i_dur = htole16(dur); }