svn commit: r224718 - head/sys/dev/ath/ath_hal

Adrian Chadd adrian at FreeBSD.org
Mon Aug 8 17:33:36 UTC 2011


Author: adrian
Date: Mon Aug  8 17:33:35 2011
New Revision: 224718
URL: http://svn.freebsd.org/changeset/base/224718

Log:
  The older HAL code sets up the regulatory domain once; FreeBSD/net80211
  allows it to be overridden at runtime.
  
  Thus, add a function which updates ah_dfsDomain after a channel set
  call to ath_hal_set_channels().
  
  Approved by:	re (kib, blanket)

Modified:
  head/sys/dev/ath/ath_hal/ah_regdomain.c

Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_regdomain.c	Mon Aug  8 16:29:07 2011	(r224717)
+++ head/sys/dev/ath/ath_hal/ah_regdomain.c	Mon Aug  8 17:33:35 2011	(r224718)
@@ -125,6 +125,8 @@ static const struct cmode modes[] = {
 	  IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D },
 };
 
+static void ath_hal_update_dfsdomain(struct ath_hal *ah);
+
 static OS_INLINE uint16_t
 getEepromRD(struct ath_hal *ah)
 {
@@ -687,9 +689,8 @@ ath_hal_init_channels(struct ath_hal *ah
     HAL_BOOL enableExtendedChannels)
 {
 	COUNTRY_CODE_TO_ENUM_RD *country;
-	REG_DOMAIN *rd5GHz = AH_NULL, *rd2GHz;
+	REG_DOMAIN *rd5GHz, *rd2GHz;
 	HAL_STATUS status;
-	HAL_DFS_DOMAIN dfsDomain = HAL_DFS_UNINIT_DOMAIN;
 
 	status = getchannels(ah, chans, maxchans, nchans, modeSelect,
 	    cc, regDmn, enableExtendedChannels, &country, &rd2GHz, &rd5GHz);
@@ -701,20 +702,12 @@ ath_hal_init_channels(struct ath_hal *ah
 		ah->ah_countryCode = country->countryCode;
 		HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, "%s: cc %u\n",
 		    __func__, ah->ah_countryCode);
+
+		/* Update current DFS domain */
+		ath_hal_update_dfsdomain(ah);
 	} else
 		status = HAL_EINVAL;
 
-	/* Update the DFS setting for the current regulatory domain */
-	if (status == HAL_OK && rd5GHz != AH_NULL) {
-		if (rd5GHz->dfsMask & DFS_FCC3)
-			dfsDomain = HAL_DFS_FCC_DOMAIN;
-		if (rd5GHz->dfsMask & DFS_ETSI)
-			dfsDomain = HAL_DFS_ETSI_DOMAIN;
-		if (rd5GHz->dfsMask & DFS_MKK4)
-			dfsDomain = HAL_DFS_MKK4_DOMAIN;
-	}
-	AH_PRIVATE(ah)->ah_dfsDomain = dfsDomain;
-
 	return status;
 }
 
@@ -759,6 +752,11 @@ ath_hal_set_channels(struct ath_hal *ah,
 		    __func__, ah->ah_countryCode);
 	} else
 		status = HAL_EINVAL;
+
+	if (status == HAL_OK) {
+		/* Update current DFS domain */
+		(void) ath_hal_update_dfsdomain(ah);
+	}
 	return status;
 }
 
@@ -824,6 +822,37 @@ ath_hal_getctl(struct ath_hal *ah, const
 	return ctl;
 }
 
+
+/*
+ * Update the current dfsDomain setting based on the given
+ * country code.
+ *
+ * Since FreeBSD/net80211 allows the channel set to change
+ * after the card has been setup (via ath_hal_init_channels())
+ * this function method is needed to update ah_dfsDomain.
+ */
+void
+ath_hal_update_dfsdomain(struct ath_hal *ah)
+{
+	const REG_DOMAIN *rd5GHz = AH_PRIVATE(ah)->ah_rd5GHz;
+	HAL_CTRY_CODE cc = ah->ah_countryCode;
+	HAL_DFS_DOMAIN dfsDomain = HAL_DFS_UNINIT_DOMAIN;
+	HAL_REG_DOMAIN regDmn = AH_PRIVATE(ah)->ah_currentRD;
+
+	HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, "%s CC: %d, RegDmn: %d\n",__func__,
+	    cc, regDmn);
+	if (rd5GHz->dfsMask & DFS_FCC3)
+		dfsDomain = HAL_DFS_FCC_DOMAIN;
+	if (rd5GHz->dfsMask & DFS_ETSI)
+		dfsDomain = HAL_DFS_ETSI_DOMAIN;
+	if (rd5GHz->dfsMask & DFS_MKK4)
+		dfsDomain = HAL_DFS_MKK4_DOMAIN;
+	AH_PRIVATE(ah)->ah_dfsDomain = dfsDomain;
+	HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, "%s ah_dfsDomain: %d\n",
+	    __func__, AH_PRIVATE(ah)->ah_dfsDomain);
+}
+
+
 /*
  * Return the max allowed antenna gain and apply any regulatory
  * domain specific changes.


More information about the svn-src-all mailing list