svn commit: r251401 - head/sys/dev/ath

Adrian Chadd adrian at FreeBSD.org
Wed Jun 5 00:45:20 UTC 2013


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) \


More information about the svn-src-all mailing list