From owner-svn-src-head@FreeBSD.ORG Wed Jun 5 00:45:20 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A687F9A1; Wed, 5 Jun 2013 00:45:20 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 98E8A1951; Wed, 5 Jun 2013 00:45:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r550jKZD051786; Wed, 5 Jun 2013 00:45:20 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r550jJ0P051783; Wed, 5 Jun 2013 00:45:19 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201306050045.r550jJ0P051783@svn.freebsd.org> From: Adrian Chadd Date: Wed, 5 Jun 2013 00:45:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251401 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Wed, 05 Jun 2013 00:45:20 -0000 Author: adrian Date: Wed Jun 5 00:45:19 2013 New Revision: 251401 URL: http://svnweb.freebsd.org/changeset/base/251401 Log: Implement a bit of a hack to store the AR9285/AR9485 RX LNA configuration in the RX antenna field. The AR9285/AR9485 use an LNA mixer to determine how to combine the signals from the two antennas. This is encoded in the RSSI fields (ctl/ext) for chain 2. So, let's use that here. This maps RX antennas 0->3 to the RX mixer configuration used to receive a frame. There's more that can be done but this is good enough to diagnose if the hardware is doing "odd" things like trying to receive frames on LNA2 (ie, antenna 2 or "alt" antenna) when there's only one antenna connected. Tested: * AR9285, STA mode Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_rx.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Wed Jun 5 00:42:04 2013 (r251400) +++ head/sys/dev/ath/if_ath.c Wed Jun 5 00:45:19 2013 (r251401) @@ -670,6 +670,7 @@ ath_attach(u_int16_t devid, struct ath_s sc->sc_rxslink = ath_hal_self_linked_final_rxdesc(ah); sc->sc_rxtsf32 = ath_hal_has_long_rxdesc_tsf(ah); sc->sc_hasenforcetxop = ath_hal_hasenforcetxop(ah); + sc->sc_rx_lnamixer = ath_hal_hasrxlnamixer(ah); if (ath_hal_hasfastframes(ah)) ic->ic_caps |= IEEE80211_C_FF; wmodes = ath_hal_getwirelessmodes(ah); Modified: head/sys/dev/ath/if_ath_rx.c ============================================================================== --- head/sys/dev/ath/if_ath_rx.c Wed Jun 5 00:42:04 2013 (r251400) +++ head/sys/dev/ath/if_ath_rx.c Wed Jun 5 00:45:19 2013 (r251401) @@ -704,6 +704,34 @@ rx_accept: rs->rs_antenna = 0; /* XXX better than nothing */ } + /* + * If this is an AR9285/AR9485, then the receive and LNA + * configuration is stored in RSSI[2] / EXTRSSI[2]. + * We can extract this out to build a much better + * receive antenna profile. + * + * Yes, this just blurts over the above RX antenna field + * for now. It's fine, the AR9285 doesn't really use + * that. + * + * Later on we should store away the fine grained LNA + * information and keep separate counters just for + * that. It'll help when debugging the AR9285/AR9485 + * combined diversity code. + */ + if (sc->sc_rx_lnamixer) { + rs->rs_antenna = 0; + + /* Bits 0:1 - the LNA configuration used */ + rs->rs_antenna |= + ((rs->rs_rssi_ctl[2] & HAL_RX_LNA_CFG_USED) + >> HAL_RX_LNA_CFG_USED_S); + + /* Bit 2 - the external RX antenna switch */ + if (rs->rs_rssi_ctl[2] & HAL_RX_LNA_EXTCFG) + rs->rs_antenna |= 0x4; + } + ifp->if_ipackets++; sc->sc_stats.ast_ant_rx[rs->rs_antenna]++; Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Wed Jun 5 00:42:04 2013 (r251400) +++ head/sys/dev/ath/if_athvar.h Wed Jun 5 00:45:19 2013 (r251401) @@ -629,8 +629,8 @@ struct ath_softc { u_int32_t sc_use_ent : 1, sc_rx_stbc : 1, sc_tx_stbc : 1, - sc_hasenforcetxop : 1; /* support enforce TxOP */ - + sc_hasenforcetxop : 1, /* support enforce TxOP */ + sc_rx_lnamixer : 1; /* RX using LNA mixing */ int sc_cabq_enable; /* Enable cabq transmission */ @@ -1269,6 +1269,8 @@ void ath_intr(void *); #define ath_hal_setenforcetxop(_ah, _v) \ ath_hal_setcapability(_ah, HAL_CAP_ENFORCE_TXOP, 1, _v, NULL) +#define ath_hal_hasrxlnamixer(_ah) \ + (ath_hal_getcapability(_ah, HAL_CAP_RX_LNA_MIXING, 0, NULL) == HAL_OK) /* EDMA definitions */ #define ath_hal_hasedma(_ah) \