Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Jun 2011 19:55:41 -0700
From:      ss griffon <ssgriffonuser@gmail.com>
To:        freebsd-wireless@freebsd.org
Subject:   Patch to move global ath hal sysctl variables to device instance variables.
Message-ID:  <BANLkTimrtNtw4sVAM%2BYp_Cqn=mFAL3MBJA@mail.gmail.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
This patch moves the global atheros hal variables defined in
ah_osdep.c to the ah_hal structure in ath_hal/ah.h

If you see any issues let me know and I will get them fixed.

[-- Attachment #2 --]
diff -r cebd29f65c23 sys/dev/ath/ah_osdep.c
--- a/sys/dev/ath/ah_osdep.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ah_osdep.c	Mon Jun 20 07:35:54 2011 -0700
@@ -76,33 +76,6 @@
 
 /* NB: put this here instead of the driver to avoid circular references */
 SYSCTL_NODE(_hw, OID_AUTO, ath, CTLFLAG_RD, 0, "Atheros driver parameters");
-SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, "Atheros HAL parameters");
-
-#ifdef AH_DEBUG
-int ath_hal_debug = 0;
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RW, &ath_hal_debug,
-	    0, "Atheros HAL debugging printfs");
-TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug);
-#endif /* AH_DEBUG */
-
-int ath_hal_ar5416_biasadj = 0;
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, ar5416_biasadj, CTLFLAG_RW,
-	&ath_hal_ar5416_biasadj, 0, "Enable 2ghz AR5416 direction sensitivity"
-	" bias adjust");
-
-/* NB: these are deprecated; they exist for now for compatibility */
-int	ath_hal_dma_beacon_response_time = 2;	/* in TU's */
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, dma_brt, CTLFLAG_RW,
-	   &ath_hal_dma_beacon_response_time, 0,
-	   "Atheros HAL DMA beacon response time");
-int	ath_hal_sw_beacon_response_time = 10;	/* in TU's */
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, sw_brt, CTLFLAG_RW,
-	   &ath_hal_sw_beacon_response_time, 0,
-	   "Atheros HAL software beacon response time");
-int	ath_hal_additional_swba_backoff = 0;	/* in TU's */
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, swba_backoff, CTLFLAG_RW,
-	   &ath_hal_additional_swba_backoff, 0,
-	   "Atheros HAL additional SWBA backoff time");
 
 MALLOC_DEFINE(M_ATH_HAL, "ath_hal", "ath hal data");
 
@@ -146,7 +119,7 @@
 void
 DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
 {
-	if ((mask == HAL_DEBUG_UNMASKABLE) || (ath_hal_debug & mask)) {
+	if ((mask == HAL_DEBUG_UNMASKABLE) || (ah->ah_config.ah_debug & mask)) {
 		__va_list ap;
 		va_start(ap, fmt);
 		ath_hal_vprintf(ah, fmt, ap);
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ah.h
--- a/sys/dev/ath/ath_hal/ah.h	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ah.h	Mon Jun 20 07:35:54 2011 -0700
@@ -756,6 +756,19 @@
 };
 typedef struct dfs_event HAL_DFS_EVENT;
 
+typedef struct
+{
+#ifdef AH_DEBUG
+	int ah_debug; /*debug flag*/
+#endif
+	int ah_ar5416_biasadj;
+
+	/* NB: these are deprecated; they exist for now for compatibility */
+	int ah_dma_beacon_response_time;     /* in TU's */
+	int ah_sw_beacon_response_time;      /* in TU's */
+	int ah_additional_swba_backoff; /* in TU's */
+}HAL_OPS_CONFIG;
+
 /*
  * Hardware Access Layer (HAL) API.
  *
@@ -784,6 +797,7 @@
 
 	uint16_t	*ah_eepromdata;	/* eeprom buffer, if needed */
 
+	HAL_OPS_CONFIG ah_config;
 	const HAL_RATE_TABLE *__ahdecl(*ah_getRateTable)(struct ath_hal *,
 				u_int mode);
 	void	  __ahdecl(*ah_detach)(struct ath_hal*);
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ah_internal.h
--- a/sys/dev/ath/ath_hal/ah_internal.h	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ah_internal.h	Mon Jun 20 07:35:54 2011 -0700
@@ -475,12 +475,6 @@
 #define	OS_A_REG_RMW_FIELD(_a, _r, _f, _v) \
 	do { OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f))) ; OS_DELAY(100); } while (0)
 
-/* system-configurable parameters */
-extern	int ath_hal_dma_beacon_response_time;	/* in TU's */
-extern	int ath_hal_sw_beacon_response_time;	/* in TU's */
-extern	int ath_hal_additional_swba_backoff;	/* in TU's */
-extern	int ath_hal_ar5416_biasadj;		/* 1 or 0 */
-
 /* wait for the register contents to have the specified value */
 extern	HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg,
 		uint32_t mask, uint32_t val);
@@ -504,11 +498,10 @@
 /* common debugging interfaces */
 #ifdef AH_DEBUG
 #include "ah_debug.h"
-extern	int ath_hal_debug;
 #define	HALDEBUG(_ah, __m, ...) \
 	do {							\
 		if ((__m) == HAL_DEBUG_UNMASKABLE ||		\
-		    (ath_hal_debug & (__m))) {			\
+		    ((_ah != AH_NULL) && (((struct ath_hal*)_ah)->ah_config.ah_debug & (__m)))) {			\
 			DO_HALDEBUG((_ah), (__m), __VA_ARGS__);	\
 		}						\
 	} while(0);
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5210/ar5210_beacon.c
--- a/sys/dev/ath/ath_hal/ar5210/ar5210_beacon.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5210/ar5210_beacon.c	Mon Jun 20 07:35:54 2011 -0700
@@ -56,9 +56,9 @@
 
 	if (AH_PRIVATE(ah)->ah_opmode != HAL_M_STA) {
 		bt.bt_nextdba = (next_beacon -
-			ath_hal_dma_beacon_response_time) << 3;	/* 1/8 TU */
+			ah->ah_config.ah_dma_beacon_response_time) << 3; /* 1/8 TU */
 		bt.bt_nextswba = (next_beacon -
-			ath_hal_sw_beacon_response_time) << 3;	/* 1/8 TU */
+            ah->ah_config.ah_sw_beacon_response_time) << 3;	/* 1/8 TU */
 		/*
 		 * The SWBA interrupt is not used for beacons in ad hoc mode
 		 * as we don't yet support ATIMs. So since the beacon never
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5211/ar5211_beacon.c
--- a/sys/dev/ath/ath_hal/ar5211/ar5211_beacon.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5211/ar5211_beacon.c	Mon Jun 20 07:35:54 2011 -0700
@@ -71,9 +71,9 @@
 	case HAL_M_IBSS:
 	case HAL_M_HOSTAP:
 		bt.bt_nextdba = (next_beacon -
-			ath_hal_dma_beacon_response_time) << 3;	/* 1/8 TU */
+			ah->ah_config.ah_dma_beacon_response_time) << 3;	/* 1/8 TU */
 		bt.bt_nextswba = (next_beacon -
-			ath_hal_sw_beacon_response_time) << 3;	/* 1/8 TU */
+            ah->ah_config.ah_sw_beacon_response_time) << 3;	/* 1/8 TU */
 		break;
 	}
 	/*
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c
--- a/sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c	Mon Jun 20 07:35:54 2011 -0700
@@ -345,8 +345,9 @@
 			| AR_Q_MISC_CBR_INCR_DIS0 | AR_Q_MISC_RDYTIME_EXP_POLICY);
 
 		value = (ahp->ah_beaconInterval
-			- (ath_hal_sw_beacon_response_time - ath_hal_dma_beacon_response_time)
-			- ath_hal_additional_swba_backoff) * 1024;
+			- (ah->ah_config.ah_sw_beacon_response_time
+			        - ah->ah_config.ah_dma_beacon_response_time)
+			- ah->ah_config.ah_additional_swba_backoff) * 1024;
 		OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);
 
 		/* Configure DCU for CAB */
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c
--- a/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c	Mon Jun 20 07:35:54 2011 -0700
@@ -84,9 +84,9 @@
 	case HAL_M_HOSTAP:
 	case HAL_M_IBSS:
 		bt.bt_nextdba = (next_beacon -
-			ath_hal_dma_beacon_response_time) << 3;	/* 1/8 TU */
+			ah->ah_config.ah_dma_beacon_response_time) << 3; /* 1/8 TU */
 		bt.bt_nextswba = (next_beacon -
-			ath_hal_sw_beacon_response_time) << 3;	/* 1/8 TU */
+            ah->ah_config.ah_sw_beacon_response_time) << 3;	/* 1/8 TU */
 		break;
 	}
 	/*
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c
--- a/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c	Mon Jun 20 07:35:54 2011 -0700
@@ -416,9 +416,9 @@
 			 * here solely for backwards compatibility.
 			 */
 			value = (ahp->ah_beaconInterval
-				- (ath_hal_sw_beacon_response_time -
-					ath_hal_dma_beacon_response_time)
-				- ath_hal_additional_swba_backoff) * 1024;
+				- (ah->ah_config.ah_sw_beacon_response_time -
+					ah->ah_config.ah_dma_beacon_response_time)
+				- ah->ah_config.ah_additional_swba_backoff) * 1024;
 			OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_ENA);
 		}
 		dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5416/ar2133.c
--- a/sys/dev/ath/ath_hal/ar5416/ar2133.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5416/ar2133.c	Mon Jun 20 07:35:54 2011 -0700
@@ -185,7 +185,7 @@
 	}
 
 	/* Workaround for hw bug - AR5416 specific */
-	if (AR_SREV_OWL(ah) && ath_hal_ar5416_biasadj)
+	if (AR_SREV_OWL(ah) && ah->ah_config.ah_ar5416_biasadj)
 		ar2133ForceBias(ah, freq);
 
 	reg32 = (channelSel << 8) | (aModeRefSel << 2) | (bModeSynth << 1) |
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c
--- a/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c	Mon Jun 20 07:35:54 2011 -0700
@@ -93,9 +93,9 @@
 		/* fall thru... */
 	case HAL_M_HOSTAP:
 		bt.bt_nextdba = (next_beacon -
-			ath_hal_dma_beacon_response_time) << 3;	/* 1/8 TU */
+			ah->ah_config.ah_dma_beacon_response_time) << 3;	/* 1/8 TU */
 		bt.bt_nextswba = (next_beacon -
-			ath_hal_sw_beacon_response_time) << 3;	/* 1/8 TU */
+            ah->ah_config.ah_sw_beacon_response_time) << 3;	/* 1/8 TU */
 		bt.bt_flags |= AR_TIMER_MODE_TBTT
 			    |  AR_TIMER_MODE_DBA
 			    |  AR_TIMER_MODE_SWBA;
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5416/ar5416_misc.c
--- a/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c	Mon Jun 20 07:35:54 2011 -0700
@@ -288,7 +288,7 @@
 			nextStart_us += OS_REG_READ(ah, AR_TSF_L32);
 		}
 		if (flag & HAL_QUIET_ADD_SWBA_RESP_TIME) {
-			nextStart_us += ath_hal_sw_beacon_response_time;
+			nextStart_us += ah->ah_config.ah_sw_beacon_response_time;
 		}
 		OS_REG_RMW_FIELD(ah, AR_QUIET1, AR_QUIET1_QUIET_ACK_CTS_ENABLE, 1);
 		OS_REG_WRITE(ah, AR_QUIET2, SM(duration, AR_QUIET2_QUIET_DUR));
diff -r cebd29f65c23 sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c
--- a/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c	Mon Jun 20 07:35:54 2011 -0700
@@ -1035,9 +1035,9 @@
 			 * here solely for backwards compatibility.
 			 */
 			value = (ahp->ah_beaconInterval
-				- (ath_hal_sw_beacon_response_time -
-					ath_hal_dma_beacon_response_time)
-				- ath_hal_additional_swba_backoff) * 1024;
+				- (ah->ah_config.ah_sw_beacon_response_time -
+					ah->ah_config.ah_dma_beacon_response_time)
+				- ah->ah_config.ah_additional_swba_backoff) * 1024;
 			OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_ENA);
 		}
 		dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
diff -r cebd29f65c23 sys/dev/ath/if_ath.c
--- a/sys/dev/ath/if_ath.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/if_ath.c	Mon Jun 20 07:35:54 2011 -0700
@@ -738,6 +738,7 @@
 	 */
 	ath_sysctlattach(sc);
 	ath_sysctl_stats_attach(sc);
+	ath_sysctl_hal_attach(sc);
 
 	if (bootverbose)
 		ieee80211_announce(ic);
diff -r cebd29f65c23 sys/dev/ath/if_ath_sysctl.c
--- a/sys/dev/ath/if_ath_sysctl.c	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/if_ath_sysctl.c	Mon Jun 20 07:35:54 2011 -0700
@@ -719,3 +719,40 @@
 	/* Attach the RX phy error array */
 	ath_sysctl_stats_attach_rxphyerr(sc, child);
 }
+
+void
+ath_sysctl_hal_attach(struct ath_softc *sc)
+{
+	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
+	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
+	struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
+
+	tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal", CTLFLAG_RD,
+	    NULL, "Atheros HAL parameters");
+	child = SYSCTL_CHILDREN(tree);
+
+#ifdef AH_DEBUG
+	sc->sc_ah->ah_config.ah_debug = 0;
+	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "debug", CTLFLAG_RW,
+			&sc->sc_ah->ah_config.ah_debug, 0, "Atheros HAL debugging printfs");
+#endif
+	sc->sc_ah->ah_config.ah_ar5416_biasadj = 0;
+    SYSCTL_ADD_INT(ctx, child, OID_AUTO, "ar5416_biasadj", CTLFLAG_RW,
+            &sc->sc_ah->ah_config.ah_ar5416_biasadj, 0,
+            "Enable 2ghz AR5416 direction sensitivity bias adjust");
+
+    sc->sc_ah->ah_config.ah_dma_beacon_response_time = 2;
+    SYSCTL_ADD_INT(ctx, child, OID_AUTO, "dma_brt", CTLFLAG_RW,
+            &sc->sc_ah->ah_config.ah_dma_beacon_response_time, 0,
+            "Atheros HAL DMA beacon response time");
+
+    sc->sc_ah->ah_config.ah_sw_beacon_response_time = 10;
+    SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sw_brt", CTLFLAG_RW,
+            &sc->sc_ah->ah_config.ah_sw_beacon_response_time, 0,
+            "Atheros HAL software beacon response time");
+
+    sc->sc_ah->ah_config.ah_additional_swba_backoff = 0;
+    SYSCTL_ADD_INT(ctx, child, OID_AUTO, "swba_backoff", CTLFLAG_RW,
+            &sc->sc_ah->ah_config.ah_additional_swba_backoff, 0,
+            "Atheros HAL additional SWBA backoff time");
+}
diff -r cebd29f65c23 sys/dev/ath/if_ath_sysctl.h
--- a/sys/dev/ath/if_ath_sysctl.h	Wed Jun 15 00:56:11 2011 -0700
+++ b/sys/dev/ath/if_ath_sysctl.h	Mon Jun 20 07:35:54 2011 -0700
@@ -34,5 +34,5 @@
 
 extern void ath_sysctlattach(struct ath_softc *);
 extern void ath_sysctl_stats_attach(struct ath_softc *sc);
-
+extern void ath_sysctl_hal_attach(struct ath_softc *sc);
 #endif
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTimrtNtw4sVAM%2BYp_Cqn=mFAL3MBJA>