From owner-svn-src-head@FreeBSD.ORG Mon Jul 23 03:52:19 2012 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 255C31065672; Mon, 23 Jul 2012 03:52:19 +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 0E6958FC14; Mon, 23 Jul 2012 03:52:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6N3qJ8V061329; Mon, 23 Jul 2012 03:52:19 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6N3qIwq061318; Mon, 23 Jul 2012 03:52:18 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201207230352.q6N3qIwq061318@svn.freebsd.org> From: Adrian Chadd Date: Mon, 23 Jul 2012 03:52:18 +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: r238710 - 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: Mon, 23 Jul 2012 03:52:19 -0000 Author: adrian Date: Mon Jul 23 03:52:18 2012 New Revision: 238710 URL: http://svn.freebsd.org/changeset/base/238710 Log: Begin separating out the TX DMA setup in preparation for TX EDMA support. * Introduce TX DMA setup/teardown methods, mirroring what's done in the RX path. Although the TX DMA descriptor is setup via ath_desc_alloc() / ath_desc_free(), there TX status descriptor ring will be allocated in this path. * Remove some of the TX EDMA capability probing from the RX path and push it into the new TX EDMA path. Added: head/sys/dev/ath/if_ath_tx_edma.c (contents, props changed) head/sys/dev/ath/if_ath_tx_edma.h (contents, props changed) Modified: head/sys/conf/files head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_rx_edma.c head/sys/dev/ath/if_ath_tx.c head/sys/dev/ath/if_ath_tx.h head/sys/dev/ath/if_ath_tx_ht.c head/sys/dev/ath/if_athvar.h head/sys/modules/ath/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/conf/files Mon Jul 23 03:52:18 2012 (r238710) @@ -729,6 +729,8 @@ dev/ath/if_ath_led.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_edma.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_tdma.c optional ath \ Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/dev/ath/if_ath.c Mon Jul 23 03:52:18 2012 (r238710) @@ -109,6 +109,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -306,8 +307,11 @@ ath_attach(u_int16_t devid, struct ath_s if (ath_hal_hasedma(sc->sc_ah)) { sc->sc_isedma = 1; ath_recv_setup_edma(sc); - } else + ath_xmit_setup_edma(sc); + } else { ath_recv_setup_legacy(sc); + ath_xmit_setup_legacy(sc); + } /* * Check if the MAC has multi-rate retry support. @@ -367,14 +371,24 @@ ath_attach(u_int16_t devid, struct ath_s ath_setcurmode(sc, IEEE80211_MODE_11A); /* - * Allocate tx+rx descriptors and populate the lists. + * Allocate TX descriptors and populate the lists. */ error = ath_desc_alloc(sc); if (error != 0) { - if_printf(ifp, "failed to allocate descriptors: %d\n", error); + if_printf(ifp, "failed to allocate TX descriptors: %d\n", + error); + goto bad; + } + error = ath_txdma_setup(sc); + if (error != 0) { + if_printf(ifp, "failed to allocate TX descriptors: %d\n", + error); goto bad; } + /* + * Allocate RX descriptors and populate the lists. + */ error = ath_rxdma_setup(sc); if (error != 0) { if_printf(ifp, "failed to allocate RX descriptors: %d\n", @@ -858,6 +872,7 @@ ath_attach(u_int16_t devid, struct ath_s bad2: ath_tx_cleanup(sc); ath_desc_free(sc); + ath_txdma_teardown(sc); ath_rxdma_teardown(sc); bad: if (ah) Modified: head/sys/dev/ath/if_ath_rx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_rx_edma.c Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/dev/ath/if_ath_rx_edma.c Mon Jul 23 03:52:18 2012 (r238710) @@ -828,9 +828,6 @@ ath_recv_setup_edma(struct ath_softc *sc /* Fetch EDMA field and buffer sizes */ (void) ath_hal_getrxstatuslen(sc->sc_ah, &sc->sc_rx_statuslen); - (void) ath_hal_gettxdesclen(sc->sc_ah, &sc->sc_tx_desclen); - (void) ath_hal_gettxstatuslen(sc->sc_ah, &sc->sc_tx_statuslen); - (void) ath_hal_getntxmaps(sc->sc_ah, &sc->sc_tx_nmaps); /* Configure the hardware with the RX buffer size */ (void) ath_hal_setrxbufsize(sc->sc_ah, sc->sc_edma_bufsize - @@ -838,14 +835,8 @@ ath_recv_setup_edma(struct ath_softc *sc device_printf(sc->sc_dev, "RX status length: %d\n", sc->sc_rx_statuslen); - device_printf(sc->sc_dev, "TX descriptor length: %d\n", - sc->sc_tx_desclen); - device_printf(sc->sc_dev, "TX status length: %d\n", - sc->sc_tx_statuslen); - device_printf(sc->sc_dev, "TX/RX buffer size: %d\n", + device_printf(sc->sc_dev, "RX buffer size: %d\n", sc->sc_edma_bufsize); - device_printf(sc->sc_dev, "TX buffers per descriptor: %d\n", - sc->sc_tx_nmaps); sc->sc_rx.recv_stop = ath_edma_stoprecv; sc->sc_rx.recv_start = ath_edma_startrecv; Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/dev/ath/if_ath_tx.c Mon Jul 23 03:52:18 2012 (r238710) @@ -4463,3 +4463,27 @@ ath_addba_response_timeout(struct ieee80 ath_tx_tid_resume(sc, atid); ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); } + +static int +ath_legacy_dma_txsetup(struct ath_softc *sc) +{ + + /* nothing new needed */ + return (0); +} + +static int +ath_legacy_dma_txteardown(struct ath_softc *sc) +{ + + /* nothing new needed */ + return (0); +} + +void +ath_xmit_setup_legacy(struct ath_softc *sc) +{ + + sc->sc_tx.xmit_setup = ath_legacy_dma_txsetup; + sc->sc_tx.xmit_teardown = ath_legacy_dma_txteardown; +} Modified: head/sys/dev/ath/if_ath_tx.h ============================================================================== --- head/sys/dev/ath/if_ath_tx.h Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/dev/ath/if_ath_tx.h Mon Jul 23 03:52:18 2012 (r238710) @@ -124,4 +124,13 @@ extern void ath_bar_response(struct ieee extern void ath_addba_response_timeout(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap); +/* + * Setup path + */ +#define ath_txdma_setup(_sc) \ + (_sc)->sc_tx.xmit_setup(_sc) +#define ath_txdma_teardown(_sc) \ + (_sc)->sc_tx.xmit_teardown(_sc) +extern void ath_xmit_setup_legacy(struct ath_softc *sc); + #endif Added: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/if_ath_tx_edma.c Mon Jul 23 03:52:18 2012 (r238710) @@ -0,0 +1,162 @@ +/*- + * Copyright (c) 2012 Adrian Chadd + * 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$"); + +/* + * Driver for the Atheros Wireless LAN controller. + * + * This software is derived from work of Atsushi Onoe; his contribution + * is greatly appreciated. + */ + +#include "opt_inet.h" +#include "opt_ath.h" +/* + * This is needed for register operations which are performed + * by the driver - eg, calls to ath_hal_gettsf32(). + * + * It's also required for any AH_DEBUG checks in here, eg the + * module dependencies. + */ +#include "opt_ah.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 /* for mp_ncpus */ + +#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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ATH_TX99_DIAG +#include +#endif + +#include + +/* + * some general macros + */ +#define INCR(_l, _sz) (_l) ++; (_l) &= ((_sz) - 1) +#define DECR(_l, _sz) (_l) --; (_l) &= ((_sz) - 1) + +MALLOC_DECLARE(M_ATHDEV); + +static int +ath_edma_dma_txsetup(struct ath_softc *sc) +{ + + /* XXX placeholder */ + return (0); +} + +static int +ath_edma_dma_txteardown(struct ath_softc *sc) +{ + + /* XXX placeholder */ + return (0); +} + +void +ath_xmit_setup_edma(struct ath_softc *sc) +{ + + /* Fetch EDMA field and buffer sizes */ + (void) ath_hal_gettxdesclen(sc->sc_ah, &sc->sc_tx_desclen); + (void) ath_hal_gettxstatuslen(sc->sc_ah, &sc->sc_tx_statuslen); + (void) ath_hal_getntxmaps(sc->sc_ah, &sc->sc_tx_nmaps); + + device_printf(sc->sc_dev, "TX descriptor length: %d\n", + sc->sc_tx_desclen); + device_printf(sc->sc_dev, "TX status length: %d\n", + sc->sc_tx_statuslen); + device_printf(sc->sc_dev, "TX buffers per descriptor: %d\n", + sc->sc_tx_nmaps); + + sc->sc_tx.xmit_setup = ath_edma_dma_txsetup; + sc->sc_tx.xmit_teardown = ath_edma_dma_txteardown; +} Added: head/sys/dev/ath/if_ath_tx_edma.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/if_ath_tx_edma.h Mon Jul 23 03:52:18 2012 (r238710) @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2012 Adrian Chadd + * 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_EDMA_H__ +#define __IF_ATH_TX_EDMA_H__ + +extern void ath_xmit_setup_edma(struct ath_softc *sc); + +#endif Modified: head/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_ht.c Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/dev/ath/if_ath_tx_ht.c Mon Jul 23 03:52:18 2012 (r238710) @@ -511,6 +511,8 @@ ath_rateseries_setup(struct ath_softc *s series[i].RateFlags |= HAL_RATESERIES_HALFGI; series[i].Rate = rt->info[rc[i].rix].rateCode; + series[i].RateIndex = rc[i].rix; + series[i].tx_power_cap = 0x3f; /* XXX? */ /* * PktDuration doesn't include slot, ACK, RTS, etc timing - Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/dev/ath/if_athvar.h Mon Jul 23 03:52:18 2012 (r238710) @@ -397,6 +397,11 @@ struct ath_rx_edma { struct mbuf *m_rxpending; }; +struct ath_tx_methods { + int (*xmit_setup)(struct ath_softc *sc); + int (*xmit_teardown)(struct ath_softc *sc); +}; + struct ath_softc { struct ifnet *sc_ifp; /* interface common */ struct ath_stats sc_stats; /* interface statistics */ @@ -412,6 +417,8 @@ struct ath_softc { struct ath_rx_methods sc_rx; struct ath_rx_edma sc_rxedma[HAL_NUM_RX_QUEUES]; /* HP/LP queues */ + struct ath_tx_methods sc_tx; + int sc_rx_statuslen; int sc_tx_desclen; int sc_tx_statuslen; Modified: head/sys/modules/ath/Makefile ============================================================================== --- head/sys/modules/ath/Makefile Mon Jul 23 02:49:25 2012 (r238709) +++ head/sys/modules/ath/Makefile Mon Jul 23 03:52:18 2012 (r238710) @@ -37,7 +37,7 @@ ATH_RATE?= sample # tx rate control alg KMOD= if_ath SRCS= if_ath.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c SRCS+= if_ath_tx.c if_ath_tx_ht.c if_ath_led.c if_ath_rx.c if_ath_tdma.c -SRCS+= if_ath_beacon.c if_ath_rx_edma.c +SRCS+= if_ath_beacon.c if_ath_rx_edma.c if_ath_tx_edma.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