svn commit: r305637 - in head/sys/dev/ath/ath_hal: . ar5416

Adrian Chadd adrian at FreeBSD.org
Fri Sep 9 04:45:27 UTC 2016


Author: adrian
Date: Fri Sep  9 04:45:25 2016
New Revision: 305637
URL: https://svnweb.freebsd.org/changeset/base/305637

Log:
  [ath_hal] fixes for finer grain timestamping, some 11n macros
  
  * change the HT_RC_2_MCS to do MCS0..23
  * Use it when looking up the ht20/ht40 array for bits-per-symbol
  * add a clk_to_psec (picoseconds) routine, so we can get sub-microsecond
    accuracy for the math
  * .. and make that + clk_to_usec public, so higher layer code that is
    returning clocks (eg the ANI diag routines, some upcoming locationing
    experiments) can be converted to microseconds.
  
  Whilst here, add a comment in ar5416 so i or someone else can revisit the
  latency values.

Modified:
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah.h
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Fri Sep  9 04:16:53 2016	(r305636)
+++ head/sys/dev/ath/ath_hal/ah.c	Fri Sep  9 04:45:25 2016	(r305637)
@@ -275,7 +275,7 @@ ath_hal_reverseBits(uint32_t val, uint32
 #define	HT_STF		4
 #define	HT_LTF(n)	((n) * 4)
 
-#define	HT_RC_2_MCS(_rc)	((_rc) & 0xf)
+#define	HT_RC_2_MCS(_rc)	((_rc) & 0x1f)
 #define	HT_RC_2_STREAMS(_rc)	((((_rc) & 0x78) >> 3) + 1)
 #define	IS_HT_RATE(_rc)		( (_rc) & IEEE80211_RATE_MCS)
 
@@ -334,9 +334,9 @@ ath_computedur_ht(uint32_t frameLen, uin
 	KASSERT((rate &~ IEEE80211_RATE_MCS) < 31, ("bad mcs 0x%x", rate));
 
 	if (isht40)
-		bitsPerSymbol = ht40_bps[rate & 0x1f];
+		bitsPerSymbol = ht40_bps[HT_RC_2_MCS(rate)];
 	else
-		bitsPerSymbol = ht20_bps[rate & 0x1f];
+		bitsPerSymbol = ht20_bps[HT_RC_2_MCS(rate)];
 	numBits = OFDM_PLCP_BITS + (frameLen << 3);
 	numSymbols = howmany(numBits, bitsPerSymbol);
 	if (isShortGI)
@@ -490,6 +490,11 @@ typedef enum {
 	WIRELESS_MODE_MAX
 } WIRELESS_MODE;
 
+/*
+ * XXX TODO: for some (?) chips, an 11b mode still runs at 11bg.
+ * Maybe AR5211 has separate 11b and 11g only modes, so 11b is 22MHz
+ * and 11g is 44MHz, but AR5416 and later run 11b in 11bg mode, right?
+ */
 static WIRELESS_MODE
 ath_hal_chan2wmode(struct ath_hal *ah, const struct ieee80211_channel *chan)
 {
@@ -543,22 +548,34 @@ ath_hal_mac_clks(struct ath_hal *ah, u_i
 u_int
 ath_hal_mac_usec(struct ath_hal *ah, u_int clks)
 {
+	uint64_t psec;
+
+	psec = ath_hal_mac_psec(ah, clks);
+	return (psec / 1000000);
+}
+
+/*
+ * XXX TODO: half, quarter rates.
+ */
+uint64_t
+ath_hal_mac_psec(struct ath_hal *ah, u_int clks)
+{
 	const struct ieee80211_channel *c = AH_PRIVATE(ah)->ah_curchan;
-	u_int usec;
+	uint64_t psec;
 
 	/* NB: ah_curchan may be null when called attach time */
 	/* XXX merlin and later specific workaround - 5ghz fast clock is 44 */
 	if (c != AH_NULL && IS_5GHZ_FAST_CLOCK_EN(ah, c)) {
-		usec = clks / CLOCK_FAST_RATE_5GHZ_OFDM;
+		psec = (clks * 1000000ULL) / CLOCK_FAST_RATE_5GHZ_OFDM;
 		if (IEEE80211_IS_CHAN_HT40(c))
-			usec >>= 1;
+			psec >>= 1;
 	} else if (c != AH_NULL) {
-		usec = clks / CLOCK_RATE[ath_hal_chan2wmode(ah, c)];
+		psec = (clks * 1000000ULL) / CLOCK_RATE[ath_hal_chan2wmode(ah, c)];
 		if (IEEE80211_IS_CHAN_HT40(c))
-			usec >>= 1;
+			psec >>= 1;
 	} else
-		usec = clks / CLOCK_RATE[WIRELESS_MODE_11b];
-	return usec;
+		psec = (clks * 1000000ULL) / CLOCK_RATE[WIRELESS_MODE_11b];
+	return psec;
 }
 
 /*

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Fri Sep  9 04:16:53 2016	(r305636)
+++ head/sys/dev/ath/ath_hal/ah.h	Fri Sep  9 04:45:25 2016	(r305637)
@@ -1674,4 +1674,11 @@ ath_hal_get_mfp_qos(struct ath_hal *ah)
 	return HAL_MFP_QOSDATA;
 }
 
+/*
+ * Convert between microseconds and core system clocks.
+ */
+extern u_int ath_hal_mac_clks(struct ath_hal *ah, u_int usecs);
+extern u_int ath_hal_mac_usec(struct ath_hal *ah, u_int clks);
+extern uint64_t ath_hal_mac_psec(struct ath_hal *ah, u_int clks);
+
 #endif /* _ATH_AH_H_ */

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Fri Sep  9 04:16:53 2016	(r305636)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Fri Sep  9 04:45:25 2016	(r305637)
@@ -727,12 +727,6 @@ ath_hal_gethwchannel(struct ath_hal *ah,
 }
 
 /*
- * Convert between microseconds and core system clocks.
- */
-extern	u_int ath_hal_mac_clks(struct ath_hal *ah, u_int usecs);
-extern	u_int ath_hal_mac_usec(struct ath_hal *ah, u_int clks);
-
-/*
  * Generic get/set capability support.  Each chip overrides
  * this routine to support chip-specific capabilities.
  */

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Fri Sep  9 04:16:53 2016	(r305636)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Fri Sep  9 04:45:25 2016	(r305637)
@@ -2833,6 +2833,9 @@ ar5416SetIFSTiming(struct ath_hal *ah, c
 		clk_44 = 1;
 
 	/* XXX does this need save/restoring for the 11n chips? */
+	/*
+	 * XXX TODO: should mask out the txlat/rxlat/usec values?
+	 */
 	refClock = OS_REG_READ(ah, AR_USEC) & AR_USEC_USEC32;
 
 	/*


More information about the svn-src-head mailing list