From owner-svn-src-head@FreeBSD.ORG Tue Feb 1 08:03:02 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 546D1106566B; Tue, 1 Feb 2011 08:03:02 +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 40C148FC0C; Tue, 1 Feb 2011 08:03:02 +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 p11832NV063407; Tue, 1 Feb 2011 08:03:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p11832lG063402; Tue, 1 Feb 2011 08:03:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201102010803.p11832lG063402@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 Feb 2011 08:03:02 +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: r218159 - in head/sys: conf dev/ath modules/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 08:03:02 -0000 Author: adrian Date: Tue Feb 1 08:03:01 2011 New Revision: 218159 URL: http://svn.freebsd.org/changeset/base/218159 Log: Include some preliminary TX HT rate scenario setup code. The AR5416 and later TX descriptors have new fields for supporting 11n bits (eg 20/40mhz mode, short/long GI) and enabling/disabling RTS/CTS protection per rate. These functions will be responsible for initialising the TX descriptors for the AR5416 and later chips for both HT and legacy frames. Beacon frames will remain using the non-11n TX descriptor setup for now; Linux ath9k does much the same. Note that these functions aren't yet used anywhere; a few more framework changes are needed before all of the right rate information is available for TX. Added: head/sys/dev/ath/if_ath_tx_ht.c (contents, props changed) head/sys/dev/ath/if_ath_tx_ht.h (contents, props changed) Modified: head/sys/conf/files head/sys/modules/ath/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Feb 1 07:58:43 2011 (r218158) +++ head/sys/conf/files Tue Feb 1 08:03:01 2011 (r218159) @@ -570,6 +570,8 @@ dev/ath/if_ath_debug.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_tx.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/if_ath_tx_ht.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_pci.c optional ath pci \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ah_osdep.c optional ath \ Added: head/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/if_ath_tx_ht.c Tue Feb 1 08:03:01 2011 (r218159) @@ -0,0 +1,204 @@ +/*- + * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet.h" +#include "opt_ath.h" +#include "opt_wlan.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#ifdef IEEE80211_SUPPORT_SUPERG +#include +#endif +#ifdef IEEE80211_SUPPORT_TDMA +#include +#endif + +#include + +#ifdef INET +#include +#include +#endif + +#include +#include /* XXX for softled */ +#include + +#ifdef ATH_TX99_DIAG +#include +#endif + +#include + +/* + * Setup a 11n rate series structure + * + * This should be called for both legacy and MCS rates. + */ +static void +ath_rateseries_setup(struct ath_softc *sc, struct ieee80211_node *ni, + HAL_11N_RATE_SERIES *series, unsigned int pktlen, uint8_t *rix, + uint8_t *try) +{ + struct ieee80211com *ic = ni->ni_ic; + struct ath_hal *ah = sc->sc_ah; + HAL_BOOL shortPreamble = AH_FALSE; + const HAL_RATE_TABLE *rt = sc->sc_currates; + int i; + uint8_t txrate; + + if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && + (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) + shortPreamble = AH_TRUE; + + memset(series, 0, sizeof(HAL_11N_RATE_SERIES) * 4); + for (i = 0; i < 4; i++) { + txrate = rt->info[rix[i]].rateCode; + series[i].Tries = try[i]; + series[i].ChSel = sc->sc_txchainmask; + if (ic->ic_protmode == IEEE80211_PROT_RTSCTS || + ic->ic_protmode == IEEE80211_PROT_CTSONLY) + series[i].RateFlags |= HAL_RATESERIES_RTS_CTS; + if (ni->ni_htcap & IEEE80211_HTCAP_CHWIDTH40) + series[i].RateFlags |= HAL_RATESERIES_2040; + if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20 || + ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) + series[i].RateFlags |= HAL_RATESERIES_HALFGI; + + /* XXX should this check the short preamble value should be set for legacy rates? -adrian */ + series[i].Rate = txrate; + + /* PktDuration doesn't include slot, ACK, RTS, etc timing - it's just the packet duration */ + if (txrate & IEEE80211_RATE_MCS) { + series[i].PktDuration = + ath_computedur_ht(pktlen + , txrate + , ic->ic_rxstream + , (ni->ni_htcap & IEEE80211_HTCAP_CHWIDTH40) + , shortPreamble); + } else { + series[i].PktDuration = ath_hal_computetxtime(ah, + rt, pktlen, rix[i], shortPreamble); + } + } +} + +#if 0 +static void +ath_rateseries_print(HAL_11N_RATE_SERIES *series) +{ + int i; + for (i = 0; i < 4; i++) { + printf("series %d: rate %x; tries %d; pktDuration %d; chSel %d; rateFlags %x\n", + i, + series[i].Rate, + series[i].Tries, + series[i].PktDuration, + series[i].ChSel, + series[i].RateFlags); + } +} +#endif + +/* + * Setup the 11n rate scenario and burst duration for the given TX descriptor + * list. + * + * This isn't useful for sending beacon frames, which has different needs + * wrt what's passed into the rate scenario function. + */ + +void +ath_buf_set_rate(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, + int pktlen, int flags, uint8_t ctsrate, uint8_t *rix, uint8_t *try) +{ + HAL_11N_RATE_SERIES series[4]; + struct ath_desc *ds = bf->bf_desc; + struct ath_desc *lastds = NULL; + struct ath_hal *ah = sc->sc_ah; + + /* Setup rate scenario */ + memset(&series, 0, sizeof(series)); + + ath_rateseries_setup(sc, ni, series, pktlen, rix, try); + + /* Enforce AR5416 aggregate limit - can't do RTS w/ an agg frame > 8k */ + + /* Enforce RTS and CTS are mutually exclusive */ + + /* Get a pointer to the last tx descriptor in the list */ + lastds = &bf->bf_desc[bf->bf_nseg - 1]; + + /* Set rate scenario */ + ath_hal_set11nratescenario(ah, ds, + ctsrate, /* rts/cts rate */ + 0, /* rts/cts duration */ + series, /* 11n rate series */ + 4, /* number of series */ + flags); + + /* Setup the last descriptor in the chain */ + ath_hal_setuplasttxdesc(ah, lastds, ds); + + /* Set burst duration */ + /* This should only be done if aggregate protection is enabled */ + //ath_hal_set11nburstduration(ah, ds, 8192); +} Added: head/sys/dev/ath/if_ath_tx_ht.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/if_ath_tx_ht.h Tue Feb 1 08:03:01 2011 (r218159) @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + * + * $FreeBSD$ + */ +#ifndef __IF_ATH_TX_HT_H__ +#define __IF_ATH_TX_HT_H__ + +extern void ath_buf_set_rate(struct ath_softc *sc, + struct ieee80211_node *ni, struct ath_buf *bf, + int pktlen, int flags, uint8_t ctsrate, uint8_t *rix, + uint8_t *try); + +#endif Modified: head/sys/modules/ath/Makefile ============================================================================== --- head/sys/modules/ath/Makefile Tue Feb 1 07:58:43 2011 (r218158) +++ head/sys/modules/ath/Makefile Tue Feb 1 08:03:01 2011 (r218159) @@ -35,7 +35,7 @@ ATH_RATE?= sample # tx rate control alg .PATH: ${.CURDIR}/../../dev/ath/ath_hal KMOD= if_ath -SRCS= if_ath.c if_ath_pci.c if_ath_debug.c if_ath_tx.c +SRCS= if_ath.c if_ath_pci.c if_ath_debug.c if_ath_tx.c if_ath_tx_ht.c # NB: v3 eeprom support used by both AR5211 and AR5212; just include it SRCS+= ah_osdep.c ah.c ah_regdomain.c ah_eeprom_v3.c SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_ath.h opt_ah.h opt_wlan.h