Author: adrian
Date: Sat Jul 30 13:25:11 2011
New Revision: 224512
URL: http://svn.freebsd.org/changeset/base/224512

Log:
  Bring over AR5416 specific RX filter get/set routines.
  
  This in particular fixes radar PHY handling - on the AR5212
  NIC, one enables the AR_PHY_ERR_RADAR bit in AR_PHY_ERR;
  the AR5416 and later also needs a bit set in AR_RX_FILTER.
  
  A follow-up commit is needed to convert the AR5416 ANI code
  to use this particular method, as it's currently using the
  AR5212 methods directly.
  
  Obtained from:        Atheros
  Approved by:  re (kib)

Modified:
  head/sys/dev/ath/ath_hal/ar5416/ar5416.h
  head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416.h    Sat Jul 30 13:22:44 2011        
(r224511)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h    Sat Jul 30 13:25:11 2011        
(r224512)
@@ -218,6 +218,8 @@ extern      HAL_BOOL ar5416ResetKeyCacheEntry
 extern HAL_BOOL ar5416SetKeyCacheEntry(struct ath_hal *ah, uint16_t entry,
               const HAL_KEYVAL *k, const uint8_t *mac, int xorKey);
 
+extern uint32_t ar5416GetRxFilter(struct ath_hal *ah);
+extern void ar5416SetRxFilter(struct ath_hal *ah, uint32_t bits);
 extern void ar5416StartPcuReceive(struct ath_hal *ah);
 extern void ar5416StopPcuReceive(struct ath_hal *ah);
 extern HAL_BOOL ar5416SetupRxDesc(struct ath_hal *,

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c     Sat Jul 30 13:22:44 
2011        (r224511)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c     Sat Jul 30 13:25:11 
2011        (r224512)
@@ -117,6 +117,8 @@ ar5416InitState(struct ath_hal_5416 *ahp
        ah->ah_resetTxQueue             = ar5416ResetTxQueue;
 
        /* Receive Functions */
+       ah->ah_getRxFilter              = ar5416GetRxFilter;
+       ah->ah_setRxFilter              = ar5416SetRxFilter;
        ah->ah_startPcuReceive          = ar5416StartPcuReceive;
        ah->ah_stopPcuReceive           = ar5416StopPcuReceive;
        ah->ah_setupRxDesc              = ar5416SetupRxDesc;

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c       Sat Jul 30 13:22:44 
2011        (r224511)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c       Sat Jul 30 13:25:11 
2011        (r224512)
@@ -27,6 +27,46 @@
 #include "ar5416/ar5416desc.h"
 
 /*
+ * Get the receive filter.
+ */
+uint32_t
+ar5416GetRxFilter(struct ath_hal *ah)
+{
+       uint32_t bits = OS_REG_READ(ah, AR_RX_FILTER);
+       uint32_t phybits = OS_REG_READ(ah, AR_PHY_ERR);
+
+       if (phybits & AR_PHY_ERR_RADAR)
+               bits |= HAL_RX_FILTER_PHYRADAR;
+       if (phybits & (AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING))
+               bits |= HAL_RX_FILTER_PHYERR;
+       return bits;
+}
+
+/*
+ * Set the receive filter.
+ */
+void
+ar5416SetRxFilter(struct ath_hal *ah, u_int32_t bits)
+{
+       uint32_t phybits;
+
+       OS_REG_WRITE(ah, AR_RX_FILTER, (bits & 0xffff));
+       phybits = 0;
+       if (bits & HAL_RX_FILTER_PHYRADAR)
+               phybits |= AR_PHY_ERR_RADAR;
+       if (bits & HAL_RX_FILTER_PHYERR)
+               phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
+       OS_REG_WRITE(ah, AR_PHY_ERR, phybits);
+       if (phybits) {
+               OS_REG_WRITE(ah, AR_RXCFG,
+                   OS_REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA);
+       } else {
+               OS_REG_WRITE(ah, AR_RXCFG,
+                   OS_REG_READ(ah, AR_RXCFG) &~ AR_RXCFG_ZLFDMA);
+       }
+}
+
+/*
  * Start receive at the PCU engine
  */
 void
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to