Bug 170904

Summary: [ath] ath driver: configure related parameters when radar detection (DFS) is enabled
Product: Base System Reporter: Brett Wright <brett.wright>
Component: wirelessAssignee: Adrian Chadd <adrian>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste, gonzo
Priority: Normal Flags: bugmeister: mfc-stable10?
bugmeister: mfc-stable9?
bugmeister: mfc-stable8?
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Brett Wright 2012-08-23 03:10:01 UTC
When enabling DFS Radar Detection in ath() driver, it makes sense to also make several other configuration changes to promote usability of radar detection:

- Disable the fast diversity stuff (ar5212 HAL)
- Disable ANI operation (ar5212 HAL)

Also a couple of other additional functions would be very helpful:

- A HAL method to fetch the default radar parameters for the chip
- Modify dfs_null to fetch the default radar parameters and disable fast diversity.
Comment 1 Glen Barber freebsd_committer freebsd_triage 2012-08-23 04:38:20 UTC
Class Changed
From-To: change-request->sw-bug



Comment 2 Glen Barber freebsd_committer freebsd_triage 2012-08-23 04:38:20 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 3 Glen Barber freebsd_committer freebsd_triage 2012-08-23 04:40:21 UTC
Class Changed
From-To: sw-bug->change-request

Undo class change with previous edit.
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2012-08-23 04:47:27 UTC
Responsible Changed
From-To: freebsd-net->freebsd-wireless

Set more canonical assignment.
Comment 5 dfilter service freebsd_committer freebsd_triage 2012-08-24 02:29:58 UTC
Author: adrian
Date: Fri Aug 24 01:29:46 2012
New Revision: 239638
URL: http://svn.freebsd.org/changeset/base/239638

Log:
  Implement an API to fetch the default DFS parameters for the given chip.
  
  The only chip this is currently implemented for is the AR5416 HAL family.
  A follow-up commit will add AR5212 support.
  
  PR:		kern/170904

Modified:
  head/sys/dev/ath/ath_hal/ah.h
  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_radar.c

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Fri Aug 24 01:14:00 2012	(r239637)
+++ head/sys/dev/ath/ath_hal/ah.h	Fri Aug 24 01:29:46 2012	(r239638)
@@ -1223,6 +1223,8 @@ struct ath_hal {
 				HAL_PHYERR_PARAM *pe);
 	void	  __ahdecl(*ah_getDfsThresh)(struct ath_hal *ah,
 				HAL_PHYERR_PARAM *pe);
+	HAL_BOOL  __ahdecl(*ah_getDfsDefaultThresh)(struct ath_hal *ah,
+				HAL_PHYERR_PARAM *pe);
 	HAL_BOOL  __ahdecl(*ah_procRadarEvent)(struct ath_hal *ah,
 				struct ath_rx_status *rxs, uint64_t fulltsf,
 				const char *buf, HAL_DFS_EVENT *event);

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416.h	Fri Aug 24 01:14:00 2012	(r239637)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h	Fri Aug 24 01:29:46 2012	(r239638)
@@ -253,6 +253,8 @@ extern	HAL_BOOL ar5416SetRifsDelay(struc
 	    const struct ieee80211_channel *chan, HAL_BOOL enable);
 
 extern	void ar5416EnableDfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);
+extern	HAL_BOOL ar5416GetDfsDefaultThresh(struct ath_hal *ah,
+	    HAL_PHYERR_PARAM *pe);
 extern	void ar5416GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);
 extern	HAL_BOOL ar5416ProcessRadarEvent(struct ath_hal *ah,
 	    struct ath_rx_status *rxs, uint64_t fulltsf, const char *buf,

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c	Fri Aug 24 01:14:00 2012	(r239637)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c	Fri Aug 24 01:29:46 2012	(r239638)
@@ -156,6 +156,7 @@ ar5416InitState(struct ath_hal_5416 *ahp
 	/* DFS Functions */
 	ah->ah_enableDfs		= ar5416EnableDfs;
 	ah->ah_getDfsThresh		= ar5416GetDfsThresh;
+	ah->ah_getDfsDefaultThresh	= ar5416GetDfsDefaultThresh;
 	ah->ah_procRadarEvent		= ar5416ProcessRadarEvent;
 	ah->ah_isFastClockEnabled	= ar5416IsFastClockEnabled;
 

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_radar.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_radar.c	Fri Aug 24 01:14:00 2012	(r239637)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_radar.c	Fri Aug 24 01:29:46 2012	(r239638)
@@ -29,6 +29,51 @@
 #include "ah_eeprom_v14.h"	/* for owl_get_ntxchains() */
 
 /*
+ * These are default parameters for the AR5416 and
+ * later 802.11n NICs.  They simply enable some
+ * radar pulse event generation.
+ *
+ * These are very likely not valid for the AR5212 era
+ * NICs.
+ *
+ * Since these define signal sizing and threshold
+ * parameters, they may need changing based on the
+ * specific antenna and receive amplifier
+ * configuration.
+ */
+#define	AR5416_DFS_FIRPWR	-33
+#define	AR5416_DFS_RRSSI	20
+#define	AR5416_DFS_HEIGHT	10
+#define	AR5416_DFS_PRSSI	15
+#define	AR5416_DFS_INBAND	15
+#define	AR5416_DFS_RELPWR	8
+#define	AR5416_DFS_RELSTEP	12
+#define	AR5416_DFS_MAXLEN	255
+
+HAL_BOOL
+ar5416GetDfsDefaultThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe)
+{
+
+	/*
+	 * These are general examples of the parameter values
+	 * to use when configuring radar pulse detection for
+	 * the AR5416, AR91xx, AR92xx NICs.  They are only
+	 * for testing and do require tuning depending upon the
+	 * hardware and deployment specifics.
+	 */
+	pe->pe_firpwr = AR5416_DFS_FIRPWR;
+	pe->pe_rrssi = AR5416_DFS_RRSSI;
+	pe->pe_height = AR5416_DFS_HEIGHT;
+	pe->pe_prssi = AR5416_DFS_PRSSI;
+	pe->pe_inband = AR5416_DFS_INBAND;
+	pe->pe_relpwr = AR5416_DFS_RELPWR;
+	pe->pe_relstep = AR5416_DFS_RELSTEP;
+	pe->pe_maxlen = AR5416_DFS_MAXLEN;
+
+	return (AH_TRUE);
+}
+
+/*
  * Get the radar parameter values and return them in the pe
  * structure
  */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 dfilter service freebsd_committer freebsd_triage 2012-08-24 08:32:51 UTC
Author: adrian
Date: Fri Aug 24 07:32:35 2012
New Revision: 239642
URL: http://svn.freebsd.org/changeset/base/239642

Log:
  Add the method to fetch the default DFS parameters for the AR5212 PHY.
  
  I need to check whether new parameters were added for the AR5413 NIC.
  
  PR:		kern/170904

Modified:
  head/sys/dev/ath/ath_hal/ar5212/ar5212.h
  head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
  head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212.h	Fri Aug 24 06:56:44 2012	(r239641)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212.h	Fri Aug 24 07:32:35 2012	(r239642)
@@ -633,6 +633,8 @@ extern	void ar5212AniReset(struct ath_ha
 extern	HAL_BOOL ar5212IsNFCalInProgress(struct ath_hal *ah);
 extern	HAL_BOOL ar5212WaitNFCalComplete(struct ath_hal *ah, int i);
 extern	void ar5212EnableDfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);
+extern	HAL_BOOL ar5212GetDfsDefaultThresh(struct ath_hal *ah,
+	    HAL_PHYERR_PARAM *pe);
 extern	void ar5212GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe);
 extern	HAL_BOOL ar5212ProcessRadarEvent(struct ath_hal *ah,
 	    struct ath_rx_status *rxs, uint64_t fulltsf, const char *buf,

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Fri Aug 24 06:56:44 2012	(r239641)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Fri Aug 24 07:32:35 2012	(r239642)
@@ -137,6 +137,7 @@ static const struct ath_hal_private ar52
 	/* DFS Functions */
 	.ah_enableDfs			= ar5212EnableDfs,
 	.ah_getDfsThresh		= ar5212GetDfsThresh,
+	.ah_getDfsDefaultThresh		= ar5212GetDfsDefaultThresh,
 	.ah_procRadarEvent		= ar5212ProcessRadarEvent,
 	.ah_isFastClockEnabled		= ar5212IsFastClockEnabled,
 	.ah_get11nExtBusy		= ar5212Get11nExtBusy,

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Fri Aug 24 06:56:44 2012	(r239641)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Fri Aug 24 07:32:35 2012	(r239642)
@@ -1163,6 +1163,35 @@ ar5212EnableDfs(struct ath_hal *ah, HAL_
 	OS_REG_WRITE(ah, AR_PHY_RADAR_0, val | AR_PHY_RADAR_0_ENA);
 }
 
+/*
+ * Parameters for the AR5212 PHY.
+ *
+ * TODO: figure out what values were added for the AR5413 and later
+ * PHY; update these here.
+ */
+#define	AR5212_DFS_FIRPWR	-41
+#define	AR5212_DFS_RRSSI	12
+#define	AR5212_DFS_HEIGHT	20
+#define	AR5212_DFS_PRSSI	22
+#define	AR5212_DFS_INBAND	6
+
+HAL_BOOL
+ar5212GetDfsDefaultThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe)
+{
+
+	pe->pe_firpwr = AR5212_DFS_FIRPWR;
+	pe->pe_rrssi = AR5212_DFS_RRSSI;
+	pe->pe_height = AR5212_DFS_HEIGHT;
+	pe->pe_prssi = AR5212_DFS_PRSSI;
+	pe->pe_inband = AR5212_DFS_INBAND;
+	/* XXX look up what is needed for the AR5413 */
+	pe->pe_relpwr = 0;
+	pe->pe_relstep = 0;
+	pe->pe_maxlen = 0;
+
+	return (AH_TRUE);
+}
+
 void
 ar5212GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe)
 {
@@ -1250,7 +1279,7 @@ ar5212Get11nExtBusy(struct ath_hal *ah)
 }
 
 /*
- * There's no channel survey support for the AR5211.
+ * There's no channel survey support for the AR5212.
  */
 HAL_BOOL
 ar5212GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 7 dfilter service freebsd_committer freebsd_triage 2012-08-24 18:37:26 UTC
Author: adrian
Date: Fri Aug 24 17:37:12 2012
New Revision: 239656
URL: http://svn.freebsd.org/changeset/base/239656

Log:
  Add an accessor macro for getting access to the default DFS parameters.
  
  PR:		kern/170904

Modified:
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/if_athvar.h
==============================================================================
--- head/sys/dev/ath/if_athvar.h	Fri Aug 24 17:08:02 2012	(r239655)
+++ head/sys/dev/ath/if_athvar.h	Fri Aug 24 17:37:12 2012	(r239656)
@@ -1185,6 +1185,8 @@ void	ath_intr(void *);
 	((*(_ah)->ah_enableDfs)((_ah), (_param)))
 #define	ath_hal_getdfsthresh(_ah, _param) \
 	((*(_ah)->ah_getDfsThresh)((_ah), (_param)))
+#define	ath_hal_getdfsdefaultthresh(_ah, _param) \
+	((*(_ah)->ah_getDfsDefaultThresh)((_ah), (_param)))
 #define	ath_hal_procradarevent(_ah, _rxs, _fulltsf, _buf, _event) \
 	((*(_ah)->ah_procRadarEvent)((_ah), (_rxs), (_fulltsf), \
 	(_buf), (_event)))
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 8 dfilter service freebsd_committer freebsd_triage 2012-08-24 18:38:05 UTC
Author: adrian
Date: Fri Aug 24 17:37:51 2012
New Revision: 239657
URL: http://svn.freebsd.org/changeset/base/239657

Log:
  Correctly handle the "pe_enabled" flag - both when configuring DFS and
  fetching the current DFS configuration.
  
  PR:		kern/170904

Modified:
  head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Fri Aug 24 17:37:12 2012	(r239656)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Fri Aug 24 17:37:51 2012	(r239657)
@@ -1160,7 +1160,12 @@ ar5212EnableDfs(struct ath_hal *ah, HAL_
 		val &= ~AR_PHY_RADAR_0_INBAND;
 		val |= SM(pe->pe_inband, AR_PHY_RADAR_0_INBAND);
 	}
-	OS_REG_WRITE(ah, AR_PHY_RADAR_0, val | AR_PHY_RADAR_0_ENA);
+	if (pe->pe_enabled)
+		val |= AR_PHY_RADAR_0_ENA;
+	else
+		val &= ~ AR_PHY_RADAR_0_ENA;
+
+	OS_REG_WRITE(ah, AR_PHY_RADAR_0, val);
 }
 
 /*
@@ -1206,6 +1211,7 @@ ar5212GetDfsThresh(struct ath_hal *ah, H
 	pe->pe_height =  MS(val, AR_PHY_RADAR_0_HEIGHT);
 	pe->pe_prssi = MS(val, AR_PHY_RADAR_0_PRSSI);
 	pe->pe_inband = MS(val, AR_PHY_RADAR_0_INBAND);
+	pe->pe_enabled = !! (val & AR_PHY_RADAR_0_ENA);
 
 	pe->pe_relpwr = 0;
 	pe->pe_relstep = 0;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 9 dfilter service freebsd_committer freebsd_triage 2012-08-24 18:40:21 UTC
Author: adrian
Date: Fri Aug 24 17:39:57 2012
New Revision: 239658
URL: http://svn.freebsd.org/changeset/base/239658

Log:
  Remove the hard-coded AR5416-series parameters and instead use the
  DFS parameters fetched from the HAL.
  
  Check whether the specific chipset supports RADAR reporting before
  enabling DFS; or some of the (unset) DFS methods may fail.
  
  Tested:
  
  * AR5210 (correctly didn't enable radar PHY reporting)
  * AR5212 (correctly enabled radar PHY reporting w/ the correct default
    parameters.)
  
  TODO:
  
  * Now that I have this capability check in place, I could remove the
    (empty) DFS methods from AR5210/AR5211.
  * Test on AR5416, AR9160, AR9280.
  
  PR:		kern/170904

Modified:
  head/sys/dev/ath/ath_dfs/null/dfs_null.c

Modified: head/sys/dev/ath/ath_dfs/null/dfs_null.c
==============================================================================
--- head/sys/dev/ath/ath_dfs/null/dfs_null.c	Fri Aug 24 17:37:51 2012	(r239657)
+++ head/sys/dev/ath/ath_dfs/null/dfs_null.c	Fri Aug 24 17:39:57 2012	(r239658)
@@ -72,28 +72,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/ath/ath_hal/ah_desc.h>
 
 /*
- * These are default parameters for the AR5416 and
- * later 802.11n NICs.  They simply enable some
- * radar pulse event generation.
- *
- * These are very likely not valid for the AR5212 era
- * NICs.
- *
- * Since these define signal sizing and threshold
- * parameters, they may need changing based on the
- * specific antenna and receive amplifier
- * configuration.
- */
-#define	AR5416_DFS_FIRPWR	-33
-#define	AR5416_DFS_RRSSI	20
-#define	AR5416_DFS_HEIGHT	10
-#define	AR5416_DFS_PRSSI	15
-#define	AR5416_DFS_INBAND	15
-#define	AR5416_DFS_RELPWR	8
-#define	AR5416_DFS_RELSTEP	12
-#define	AR5416_DFS_MAXLEN	255
-
-/*
  * Methods which are required
  */
 
@@ -125,30 +103,27 @@ ath_dfs_radar_enable(struct ath_softc *s
 #if 0
 	HAL_PHYERR_PARAM pe;
 
+	/* Check if the hardware supports radar reporting */
+	/* XXX TODO: migrate HAL_CAP_RADAR/HAL_CAP_AR to somewhere public! */
+	if (ath_hal_getcapability(sc->sc_ah,
+	    HAL_CAP_PHYDIAG, 0, NULL) != HAL_OK)
+		return (0);
+
 	/* Check if the current channel is radar-enabled */
 	if (! IEEE80211_IS_CHAN_DFS(chan))
 		return (0);
 
+	/* Fetch the default parameters */
+	memset(&pe, '\0', sizeof(pe));
+	if (! ath_hal_getdfsdefaultthresh(sc->sc_ah, &pe))
+		return (0);
+
 	/* Enable radar PHY error reporting */
 	sc->sc_dodfs = 1;
 
-	/*
-	 * These are general examples of the parameter values
-	 * to use when configuring radar pulse detection for
-	 * the AR5416, AR91xx, AR92xx NICs.  They are only
-	 * for testing and do require tuning depending upon the
-	 * hardware and deployment specifics.
-	 */
-	pe.pe_firpwr = AR5416_DFS_FIRPWR;
-	pe.pe_rrssi = AR5416_DFS_RRSSI;
-	pe.pe_height = AR5416_DFS_HEIGHT;
-	pe.pe_prssi = AR5416_DFS_PRSSI;
-	pe.pe_inband = AR5416_DFS_INBAND;
-	pe.pe_relpwr = AR5416_DFS_RELPWR;
-	pe.pe_relstep = AR5416_DFS_RELSTEP;
-	pe.pe_maxlen = AR5416_DFS_MAXLEN;
+	/* Tell the hardware to enable radar reporting */
 	pe.pe_enabled = 1;
-	
+
 	/* Flip on extension channel events only if doing HT40 */
 	if (IEEE80211_IS_CHAN_HT40(chan))
 		pe.pe_extchannel = 1;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 10 dfilter service freebsd_committer freebsd_triage 2012-08-29 04:58:29 UTC
Author: adrian
Date: Wed Aug 29 03:58:13 2012
New Revision: 239801
URL: http://svn.freebsd.org/changeset/base/239801

Log:
  Add AR5413 radar parameters and strong signal diversity capability.
  
  This is a re-implementation based on the reference carrier code
  for the AR5413.
  
  Tested:
   * Pulse detection for AR5212 and AR5413, to ensure the
     correct behaviour for both chips
  
  PR:		kern/170904
  Obtained from:	Qualcomm Atheros

Modified:
  head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
  head/sys/dev/ath/ath_hal/ar5212/ar5212phy.h

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Wed Aug 29 03:50:59 2012	(r239800)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Wed Aug 29 03:58:13 2012	(r239801)
@@ -843,6 +843,10 @@ ar5212GetCapability(struct ath_hal *ah, 
 			return HAL_OK;
 		case 1:			/* current setting */
 			return ahp->ah_diversity ? HAL_OK : HAL_ENXIO;
+		case HAL_CAP_STRONG_DIV:
+			*result = OS_REG_READ(ah, AR_PHY_RESTART);
+			*result = MS(*result, AR_PHY_RESTART_DIV_GC);
+			return HAL_OK;
 		}
 		return HAL_EINVAL;
 	case HAL_CAP_DIAG:
@@ -950,16 +954,34 @@ ar5212SetCapability(struct ath_hal *ah, 
 		OS_REG_WRITE(ah, AR_MISC_MODE, OS_REG_READ(ah, AR_MISC_MODE) | ahp->ah_miscMode);
 		return AH_TRUE;
 	case HAL_CAP_DIVERSITY:
-		if (ahp->ah_phyPowerOn) {
-			v = OS_REG_READ(ah, AR_PHY_CCK_DETECT);
-			if (setting)
-				v |= AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
-			else
-				v &= ~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
-			OS_REG_WRITE(ah, AR_PHY_CCK_DETECT, v);
+		switch (capability) {
+		case 0:
+			return AH_FALSE;
+		case 1:	/* setting */
+			if (ahp->ah_phyPowerOn) {
+				if (capability == HAL_CAP_STRONG_DIV) {
+							}
+				v = OS_REG_READ(ah, AR_PHY_CCK_DETECT);
+				if (setting)
+					v |= AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
+				else
+					v &= ~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
+				OS_REG_WRITE(ah, AR_PHY_CCK_DETECT, v);
+			}
+			ahp->ah_diversity = (setting != 0);
+			return AH_TRUE;
+
+		case HAL_CAP_STRONG_DIV:
+			if (! ahp->ah_phyPowerOn)
+				return AH_FALSE;
+			v = OS_REG_READ(ah, AR_PHY_RESTART);
+			v &= ~AR_PHY_RESTART_DIV_GC;
+			v |= SM(setting, AR_PHY_RESTART_DIV_GC);
+			OS_REG_WRITE(ah, AR_PHY_RESTART, v);
+			return AH_TRUE;
+		default:
+			return AH_FALSE;
 		}
-		ahp->ah_diversity = (setting != 0);
-		return AH_TRUE;
 	case HAL_CAP_DIAG:		/* hardware diagnostic support */
 		/*
 		 * NB: could split this up into virtual capabilities,
@@ -1165,14 +1187,61 @@ ar5212EnableDfs(struct ath_hal *ah, HAL_
 	else
 		val &= ~ AR_PHY_RADAR_0_ENA;
 
+	if (IS_5413(ah)) {
+
+		if (pe->pe_blockradar == 1)
+			OS_REG_SET_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_BLOCKOFDMWEAK);
+		else
+			OS_REG_CLR_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_BLOCKOFDMWEAK);
+
+		if (pe->pe_en_relstep_check == 1)
+			OS_REG_SET_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_ENRELSTEPCHK);
+		else
+			OS_REG_CLR_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_ENRELSTEPCHK);
+
+		if (pe->pe_usefir128 == 1)
+			OS_REG_SET_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_USEFIR128);
+		else
+			OS_REG_CLR_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_USEFIR128);
+
+		if (pe->pe_enmaxrssi == 1)
+			OS_REG_SET_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_ENMAXRSSI);
+		else
+			OS_REG_CLR_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_ENMAXRSSI);
+
+		if (pe->pe_enrelpwr == 1)
+			OS_REG_SET_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_ENRELPWRCHK);
+		else
+			OS_REG_CLR_BIT(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_ENRELPWRCHK);
+
+		if (pe->pe_relpwr != HAL_PHYERR_PARAM_NOVAL)
+			OS_REG_RMW_FIELD(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_RELPWR, pe->pe_relpwr);
+
+		if (pe->pe_relstep != HAL_PHYERR_PARAM_NOVAL)
+			OS_REG_RMW_FIELD(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_RELSTEP, pe->pe_relstep);
+
+		if (pe->pe_maxlen != HAL_PHYERR_PARAM_NOVAL)
+			OS_REG_RMW_FIELD(ah, AR_PHY_RADAR_2,
+			    AR_PHY_RADAR_2_MAXLEN, pe->pe_maxlen);
+	}
+
 	OS_REG_WRITE(ah, AR_PHY_RADAR_0, val);
 }
 
 /*
  * Parameters for the AR5212 PHY.
- *
- * TODO: figure out what values were added for the AR5413 and later
- * PHY; update these here.
  */
 #define	AR5212_DFS_FIRPWR	-41
 #define	AR5212_DFS_RRSSI	12
@@ -1180,19 +1249,52 @@ ar5212EnableDfs(struct ath_hal *ah, HAL_
 #define	AR5212_DFS_PRSSI	22
 #define	AR5212_DFS_INBAND	6
 
+/*
+ * Default parameters for the AR5413 PHY.
+ */
+#define	AR5413_DFS_FIRPWR	-34
+#define	AR5413_DFS_RRSSI	20
+#define	AR5413_DFS_HEIGHT	10
+#define	AR5413_DFS_PRSSI	15
+#define	AR5413_DFS_INBAND	6
+#define	AR5413_DFS_RELPWR	8
+#define	AR5413_DFS_RELSTEP	31
+#define	AR5413_DFS_MAXLEN	255
+
+
 HAL_BOOL
 ar5212GetDfsDefaultThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe)
 {
 
-	pe->pe_firpwr = AR5212_DFS_FIRPWR;
-	pe->pe_rrssi = AR5212_DFS_RRSSI;
-	pe->pe_height = AR5212_DFS_HEIGHT;
-	pe->pe_prssi = AR5212_DFS_PRSSI;
-	pe->pe_inband = AR5212_DFS_INBAND;
-	/* XXX look up what is needed for the AR5413 */
-	pe->pe_relpwr = 0;
-	pe->pe_relstep = 0;
-	pe->pe_maxlen = 0;
+	if (IS_5413(ah)) {
+		pe->pe_firpwr = AR5413_DFS_FIRPWR;
+		pe->pe_rrssi = AR5413_DFS_RRSSI;
+		pe->pe_height = AR5413_DFS_HEIGHT;
+		pe->pe_prssi = AR5413_DFS_PRSSI;
+		pe->pe_inband = AR5413_DFS_INBAND;
+		pe->pe_relpwr = AR5413_DFS_RELPWR;
+		pe->pe_relstep = AR5413_DFS_RELSTEP;
+		pe->pe_maxlen = AR5413_DFS_MAXLEN;
+		pe->pe_usefir128 = 0;
+		pe->pe_blockradar = 1;
+		pe->pe_enmaxrssi = 1;
+		pe->pe_enrelpwr = 1;
+		pe->pe_en_relstep_check = 0;
+	} else {
+		pe->pe_firpwr = AR5212_DFS_FIRPWR;
+		pe->pe_rrssi = AR5212_DFS_RRSSI;
+		pe->pe_height = AR5212_DFS_HEIGHT;
+		pe->pe_prssi = AR5212_DFS_PRSSI;
+		pe->pe_inband = AR5212_DFS_INBAND;
+		pe->pe_relpwr = 0;
+		pe->pe_relstep = 0;
+		pe->pe_maxlen = 0;
+		pe->pe_usefir128 = 0;
+		pe->pe_blockradar = 0;
+		pe->pe_enmaxrssi = 0;
+		pe->pe_enrelpwr = 0;
+		pe->pe_en_relstep_check = 0;
+	}
 
 	return (AH_TRUE);
 }
@@ -1216,7 +1318,26 @@ ar5212GetDfsThresh(struct ath_hal *ah, H
 	pe->pe_relpwr = 0;
 	pe->pe_relstep = 0;
 	pe->pe_maxlen = 0;
+	pe->pe_usefir128 = 0;
+	pe->pe_blockradar = 0;
+	pe->pe_enmaxrssi = 0;
+	pe->pe_enrelpwr = 0;
+	pe->pe_en_relstep_check = 0;
 	pe->pe_extchannel = AH_FALSE;
+
+	if (IS_5413(ah)) {
+		val = OS_REG_READ(ah, AR_PHY_RADAR_2);
+		pe->pe_relpwr = !! MS(val, AR_PHY_RADAR_2_RELPWR);
+		pe->pe_relstep = !! MS(val, AR_PHY_RADAR_2_RELSTEP);
+		pe->pe_maxlen = !! MS(val, AR_PHY_RADAR_2_MAXLEN);
+
+		pe->pe_usefir128 = !! (val & AR_PHY_RADAR_2_USEFIR128);
+		pe->pe_blockradar = !! (val & AR_PHY_RADAR_2_BLOCKOFDMWEAK);
+		pe->pe_enmaxrssi = !! (val & AR_PHY_RADAR_2_ENMAXRSSI);
+		pe->pe_enrelpwr = !! (val & AR_PHY_RADAR_2_ENRELPWRCHK);
+		pe->pe_en_relstep_check =
+		    !! (val & AR_PHY_RADAR_2_ENRELSTEPCHK);
+	}
 }
 
 /*

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212phy.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212phy.h	Wed Aug 29 03:50:59 2012	(r239800)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212phy.h	Wed Aug 29 03:58:13 2012	(r239801)
@@ -221,6 +221,19 @@
 #define AR_PHY_RADAR_0_FIRPWR	0x7F000000	/* Radar firpwr threshold */
 #define AR_PHY_RADAR_0_FIRPWR_S	24
 
+/* ar5413 specific */
+#define	AR_PHY_RADAR_2		0x9958		/* radar detection settings */
+#define	AR_PHY_RADAR_2_ENRELSTEPCHK 0x00002000	/* Enable using max rssi */
+#define	AR_PHY_RADAR_2_ENMAXRSSI    0x00004000	/* Enable using max rssi */
+#define	AR_PHY_RADAR_2_BLOCKOFDMWEAK 0x00008000	/* En block OFDM weak sig as radar */
+#define	AR_PHY_RADAR_2_USEFIR128    0x00400000	/* En measuring pwr over 128 cycles */
+#define	AR_PHY_RADAR_2_ENRELPWRCHK  0x00800000	/* Enable using max rssi */
+#define	AR_PHY_RADAR_2_MAXLEN	0x000000FF	/* Max Pulse duration threshold */
+#define	AR_PHY_RADAR_2_MAXLEN_S	0
+#define	AR_PHY_RADAR_2_RELSTEP	0x00001F00	/* Pulse relative step threshold */
+#define	AR_PHY_RADAR_2_RELSTEP_S	8
+#define	AR_PHY_RADAR_2_RELPWR	0x003F0000	/* pulse relative power threshold */
+#define	AR_PHY_RADAR_2_RELPWR_S	16
 
 #define	AR_PHY_SIGMA_DELTA	0x996C      /* AR5312 only */
 #define	AR_PHY_SIGMA_DELTA_ADC_SEL	0x00000003
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 11 Mark Linimon freebsd_committer freebsd_triage 2013-02-24 23:15:02 UTC
State Changed
From-To: open->patched

Over to committer for possible MFC. 


Comment 12 Mark Linimon freebsd_committer freebsd_triage 2013-02-24 23:15:02 UTC
Responsible Changed
From-To: freebsd-wireless->adrian
Comment 13 Ed Maste freebsd_committer freebsd_triage 2018-10-04 00:46:41 UTC
Adrian is this complete?
Comment 14 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-20 01:30:45 UTC
There was a commit referencing this bug, but it's still not closed and has been inactive for some time. Closing as fixed. Please re-open it if the issue hasn't been completely resolved.