From owner-svn-src-head@FreeBSD.ORG Tue Feb 1 07:50:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42B32106564A; Tue, 1 Feb 2011 07:50:27 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3018F8FC13; Tue, 1 Feb 2011 07:50:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p117oRid063000; Tue, 1 Feb 2011 07:50:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p117oRuM062998; Tue, 1 Feb 2011 07:50:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201102010750.p117oRuM062998@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 Feb 2011 07:50:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218157 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Feb 2011 07:50:27 -0000 Author: adrian Date: Tue Feb 1 07:50:26 2011 New Revision: 218157 URL: http://svn.freebsd.org/changeset/base/218157 Log: Refator the common code which calculates the 802.11g protection duration. Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Tue Feb 1 07:10:13 2011 (r218156) +++ head/sys/dev/ath/if_ath_tx.c Tue Feb 1 07:50:26 2011 (r218157) @@ -419,6 +419,46 @@ ath_tx_tag_crypto(struct ath_softc *sc, return 1; } +static void +ath_tx_calc_ctsduration(struct ath_hal *ah, int rix, int cix, + int shortPreamble, int pktlen, const HAL_RATE_TABLE *rt, + int flags, u_int8_t *ctsrate, int *ctsduration) +{ + /* + * CTS transmit rate is derived from the transmit rate + * by looking in the h/w rate table. We must also factor + * in whether or not a short preamble is to be used. + */ + /* NB: cix is set above where RTS/CTS is enabled */ + KASSERT(cix != 0xff, ("cix not setup")); + (*ctsrate) = rt->info[cix].rateCode; + /* + * Compute the transmit duration based on the frame + * size and the size of an ACK frame. We call into the + * HAL to do the computation since it depends on the + * characteristics of the actual PHY being used. + * + * NB: CTS is assumed the same size as an ACK so we can + * use the precalculated ACK durations. + */ + if (shortPreamble) { + (*ctsrate) |= rt->info[cix].shortPreamble; + if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ + (*ctsduration) += rt->info[cix].spAckDuration; + (*ctsduration) += ath_hal_computetxtime(ah, + rt, pktlen, rix, AH_TRUE); + if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ + (*ctsduration) += rt->info[rix].spAckDuration; + } else { + if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ + (*ctsduration) += rt->info[cix].lpAckDuration; + (*ctsduration) += ath_hal_computetxtime(ah, + rt, pktlen, rix, AH_FALSE); + if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ + (*ctsduration) += rt->info[rix].lpAckDuration; + } +} + int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, struct mbuf *m0) @@ -669,39 +709,8 @@ ath_tx_start(struct ath_softc *sc, struc */ ctsduration = 0; if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) { - /* - * CTS transmit rate is derived from the transmit rate - * by looking in the h/w rate table. We must also factor - * in whether or not a short preamble is to be used. - */ - /* NB: cix is set above where RTS/CTS is enabled */ - KASSERT(cix != 0xff, ("cix not setup")); - ctsrate = rt->info[cix].rateCode; - /* - * Compute the transmit duration based on the frame - * size and the size of an ACK frame. We call into the - * HAL to do the computation since it depends on the - * characteristics of the actual PHY being used. - * - * NB: CTS is assumed the same size as an ACK so we can - * use the precalculated ACK durations. - */ - if (shortPreamble) { - ctsrate |= rt->info[cix].shortPreamble; - if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ - ctsduration += rt->info[cix].spAckDuration; - ctsduration += ath_hal_computetxtime(ah, - rt, pktlen, rix, AH_TRUE); - if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ - ctsduration += rt->info[rix].spAckDuration; - } else { - if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ - ctsduration += rt->info[cix].lpAckDuration; - ctsduration += ath_hal_computetxtime(ah, - rt, pktlen, rix, AH_FALSE); - if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ - ctsduration += rt->info[rix].lpAckDuration; - } + (void) ath_tx_calc_ctsduration(ah, rix, cix, shortPreamble, pktlen, + rt, flags, &ctsrate, &ctsduration); /* * Must disable multi-rate retry when using RTS/CTS. */ @@ -856,29 +865,20 @@ ath_tx_raw_start(struct ath_softc *sc, s txantenna = params->ibp_pri >> 2; if (txantenna == 0) /* XXX? */ txantenna = sc->sc_txantenna; + ctsduration = 0; - if (flags & (HAL_TXDESC_CTSENA | HAL_TXDESC_RTSENA)) { + if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) { cix = ath_tx_findrix(sc, params->ibp_ctsrate); - ctsrate = rt->info[cix].rateCode; - if (params->ibp_flags & IEEE80211_BPF_SHORTPRE) { - ctsrate |= rt->info[cix].shortPreamble; - if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ - ctsduration += rt->info[cix].spAckDuration; - ctsduration += ath_hal_computetxtime(ah, - rt, pktlen, rix, AH_TRUE); - if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ - ctsduration += rt->info[rix].spAckDuration; - } else { - if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ - ctsduration += rt->info[cix].lpAckDuration; - ctsduration += ath_hal_computetxtime(ah, - rt, pktlen, rix, AH_FALSE); - if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ - ctsduration += rt->info[rix].lpAckDuration; - } + (void) ath_tx_calc_ctsduration(ah, rix, cix, + params->ibp_flags & IEEE80211_BPF_SHORTPRE, pktlen, + rt, flags, &ctsrate, &ctsduration); + /* + * Must disable multi-rate retry when using RTS/CTS. + */ ismrr = 0; /* XXX */ } else ctsrate = 0; + pri = params->ibp_pri & 3; /* * NB: we mark all packets as type PSPOLL so the h/w won't