PERFORCE change 115002 for review

Sam Leffler sam at FreeBSD.org
Sun Feb 25 00:31:14 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=115002

Change 115002 by sam at sam_ebb on 2007/02/25 00:30:36

	IFC sysctl fixes

Affected files ...

.. //depot/projects/wifi/sys/dev/ath/if_ath.c#135 integrate
.. //depot/projects/wifi/sys/dev/ath/if_athvar.h#54 integrate

Differences ...

==== //depot/projects/wifi/sys/dev/ath/if_ath.c#135 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.160 2007/01/21 19:32:50 marius Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.162 2007/02/24 23:23:29 sam Exp $");
 
 /*
  * Driver for the Atheros Wireless LAN controller.
@@ -6001,6 +6001,29 @@
 }
 
 static int
+ath_sysctl_txantenna(SYSCTL_HANDLER_ARGS)
+{
+	struct ath_softc *sc = arg1;
+	u_int txantenna = ath_hal_getantennaswitch(sc->sc_ah);
+	int error;
+
+	error = sysctl_handle_int(oidp, &txantenna, 0, req);
+	if (!error && req->newptr) {
+		/* XXX assumes 2 antenna ports */
+		if (txantenna < HAL_ANT_VARIABLE || txantenna > HAL_ANT_FIXED_B)
+			return EINVAL;
+		ath_hal_setantennaswitch(sc->sc_ah, txantenna);
+		/*
+		 * NB: with the switch locked this isn't meaningful,
+		 *     but set it anyway so things like radiotap get
+		 *     consistent info in their data.
+		 */
+		sc->sc_txantenna = txantenna;
+	}
+	return error;
+}
+
+static int
 ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS)
 {
 	struct ath_softc *sc = arg1;
@@ -6056,7 +6079,8 @@
 	error = sysctl_handle_int(oidp, &scale, 0, req);
 	if (error || !req->newptr)
 		return error;
-	return !ath_hal_settpscale(sc->sc_ah, scale) ? EINVAL : ath_reset(ifp);
+	return !ath_hal_settpscale(sc->sc_ah, scale) ? EINVAL :
+	    (ifp->if_drv_flags & IFF_DRV_RUNNING) ? ath_reset(ifp) : 0;
 }
 
 static int
@@ -6076,13 +6100,15 @@
 ath_sysctl_rfkill(SYSCTL_HANDLER_ARGS)
 {
 	struct ath_softc *sc = arg1;
+	struct ifnet *ifp = sc->sc_ifp;
 	u_int rfkill = ath_hal_getrfkill(sc->sc_ah);
 	int error;
 
 	error = sysctl_handle_int(oidp, &rfkill, 0, req);
 	if (error || !req->newptr)
 		return error;
-	return !ath_hal_setrfkill(sc->sc_ah, rfkill) ? EINVAL : 0;
+	return !ath_hal_setrfkill(sc->sc_ah, rfkill) ? EINVAL :
+	    (ifp->if_drv_flags & IFF_DRV_RUNNING) ? ath_reset(ifp) : 0;
 }
 
 static int
@@ -6209,9 +6235,9 @@
 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
 		"ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0,
 		"idle time for inactivity LED (ticks)");
-	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
-		"txantenna", CTLFLAG_RW, &sc->sc_txantenna, 0,
-		"tx antenna (0=auto)");
+	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+		"txantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
+		ath_sysctl_txantenna, "I", "antenna switch");
 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
 		"rxantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
 		ath_sysctl_rxantenna, "I", "default/rx antenna");

==== //depot/projects/wifi/sys/dev/ath/if_athvar.h#54 (text+ko) ====

@@ -33,7 +33,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.58 2007/01/15 04:26:19 sam Exp $
+ * $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.59 2007/02/24 23:12:58 sam Exp $
  */
 
 /*
@@ -507,6 +507,10 @@
 	(ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 1, NULL) == HAL_OK)
 #define	ath_hal_setdiversity(_ah, _v) \
 	ath_hal_setcapability(_ah, HAL_CAP_DIVERSITY, 1, _v, NULL)
+#define	ath_hal_getantennaswitch(_ah) \
+	((*(_ah)->ah_getAntennaSwitch)((_ah)))
+#define	ath_hal_setantennaswitch(_ah, _v) \
+	((*(_ah)->ah_setAntennaSwitch)((_ah), (_v)))
 #define	ath_hal_getdiag(_ah, _pv) \
 	(ath_hal_getcapability(_ah, HAL_CAP_DIAG, 0, _pv) == HAL_OK)
 #define	ath_hal_setdiag(_ah, _v) \


More information about the p4-projects mailing list