svn commit: r184559 - in head/sys: conf modules/rl pci

Warner Losh imp at FreeBSD.org
Sun Nov 2 08:50:59 PST 2008


Author: imp
Date: Sun Nov  2 16:50:57 2008
New Revision: 184559
URL: http://svn.freebsd.org/changeset/base/184559

Log:
  Make RL_TWISTER_ENABLE a tunable/sysctl.  Eliminate it as an option.
  Fix module build.
  
  Submitted by:	Kostik Belousov

Modified:
  head/sys/conf/options
  head/sys/modules/rl/Makefile
  head/sys/pci/if_rl.c
  head/sys/pci/if_rlreg.h

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Sun Nov  2 12:50:16 2008	(r184558)
+++ head/sys/conf/options	Sun Nov  2 16:50:57 2008	(r184559)
@@ -672,9 +672,6 @@ ED_SIC			opt_ed.h
 # bce driver
 BCE_DEBUG		opt_bce.h
 
-# rl driver
-RL_TWISTER_ENABLE	opt_rl.h
-
 SOCKBUF_DEBUG		opt_global.h
 
 # options for ubsec driver

Modified: head/sys/modules/rl/Makefile
==============================================================================
--- head/sys/modules/rl/Makefile	Sun Nov  2 12:50:16 2008	(r184558)
+++ head/sys/modules/rl/Makefile	Sun Nov  2 16:50:57 2008	(r184559)
@@ -3,7 +3,7 @@
 .PATH: ${.CURDIR}/../../pci
 
 KMOD=	if_rl
-SRCS=	if_rl.c device_if.h bus_if.h pci_if.h opt_rl.h
+SRCS=	if_rl.c device_if.h bus_if.h pci_if.h
 SRCS+=	miibus_if.h
 
 .include <bsd.kmod.mk>

Modified: head/sys/pci/if_rl.c
==============================================================================
--- head/sys/pci/if_rl.c	Sun Nov  2 12:50:16 2008	(r184558)
+++ head/sys/pci/if_rl.c	Sun Nov  2 16:50:57 2008	(r184559)
@@ -85,7 +85,6 @@ __FBSDID("$FreeBSD$");
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS
 #include "opt_device_polling.h"
-#include "opt_rl.h"
 #endif
 
 #include <sys/param.h>
@@ -97,6 +96,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/socket.h>
+#include <sys/sysctl.h>
 
 #include <net/if.h>
 #include <net/if_arp.h>
@@ -801,14 +801,25 @@ rl_attach(device_t dev)
 	struct ifnet		*ifp;
 	struct rl_softc		*sc;
 	struct rl_type		*t;
+	struct sysctl_ctx_list	*ctx;
+	struct sysctl_oid_list	*children;
 	int			error = 0, i, rid;
 	int			unit;
 	uint16_t		rl_did = 0;
+	char			tn[32];
 
 	sc = device_get_softc(dev);
 	unit = device_get_unit(dev);
 	sc->rl_dev = dev;
 
+	sc->rl_twister_enable = 0;
+	snprintf(tn, sizeof(tn), "dev.rl.%d.twister_enable", unit);
+	TUNABLE_INT_FETCH(tn, &sc->rl_twister_enable);
+	ctx = device_get_sysctl_ctx(sc->rl_dev);
+	children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->rl_dev));
+	SYSCTL_ADD_INT(ctx, children, OID_AUTO, "twister_enable", CTLFLAG_RD,
+	   &sc->rl_twister_enable, 0, "");
+
 	mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
 	    MTX_DEF);
 	callout_init_mtx(&sc->rl_stat_callout, &sc->rl_mtx, 0);
@@ -1384,7 +1395,6 @@ rl_txeof(struct rl_softc *sc)
 		sc->rl_watchdog_timer = 0;
 }
 
-#ifdef RL_TWISTER_ENABLE
 static void
 rl_twister_update(struct rl_softc *sc)
 {
@@ -1483,7 +1493,6 @@ rl_twister_update(struct rl_softc *sc)
 	}
 	
 }
-#endif
 
 static void
 rl_tick(void *xsc)
@@ -1506,19 +1515,19 @@ rl_tick(void *xsc)
 	 */
 	mii = device_get_softc(sc->rl_miibus);
 	mii_tick(mii);
-#ifdef RL_TWISTER_ENABLE
-	if (sc->rl_twister == DONE)
+	if (sc->rl_twister_enable) {
+		if (sc->rl_twister == DONE)
+			rl_watchdog(sc);
+		else
+			rl_twister_update(sc);
+		if (sc->rl_twister == DONE)
+			ticks = hz;
+		else
+			ticks = hz / 10;
+	} else {
 		rl_watchdog(sc);
-	else
-		rl_twister_update(sc);
-	if (sc->rl_twister == DONE)
 		ticks = hz;
-	else
-		ticks = hz / 10;
-#else
-	rl_watchdog(sc);
-	ticks = hz;
-#endif
+	}
 
 	callout_reset(&sc->rl_stat_callout, ticks, rl_tick, sc);
 }
@@ -1768,14 +1777,15 @@ rl_init_locked(struct rl_softc *sc)
 	rl_stop(sc);
 
 	rl_reset(sc);
-#ifdef RL_TWISTER_ENABLE
-	/*
-	 * Reset twister register tuning state.  The twister registers
-	 * and their tuning are undocumented, but are necessary to cope
-	 * with bad links.  rl_twister = DONE here will disable this entirely.
-	 */
-	sc->rl_twister = CHK_LINK;
-#endif
+	if (sc->rl_twister_enable) {
+		/*
+		 * Reset twister register tuning state.  The twister
+		 * registers and their tuning are undocumented, but
+		 * are necessary to cope with bad links.  rl_twister =
+		 * DONE here will disable this entirely.
+		 */
+		sc->rl_twister = CHK_LINK;
+	}
 
 	/*
 	 * Init our MAC address.  Even though the chipset

Modified: head/sys/pci/if_rlreg.h
==============================================================================
--- head/sys/pci/if_rlreg.h	Sun Nov  2 12:50:16 2008	(r184558)
+++ head/sys/pci/if_rlreg.h	Sun Nov  2 16:50:57 2008	(r184559)
@@ -830,9 +830,7 @@ struct rl_list_data {
 	bus_addr_t		rl_tx_list_addr;
 };
 
-#ifdef RL_TWISTER_ENABLE
 enum rl_twist { DONE, CHK_LINK, FIND_ROW, SET_PARAM, RECHK_LONG, RETUNE };
-#endif
 
 struct rl_softc {
 	struct ifnet		*rl_ifp;	/* interface info */
@@ -862,11 +860,10 @@ struct rl_softc {
 	uint32_t		rl_rxlenmask;
 	int			rl_testmode;
 	int			rl_if_flags;
-#ifdef RL_TWISTER_ENABLE
+	int			rl_twister_enable;
 	enum rl_twist		rl_twister;
 	int			rl_twist_row;
 	int			rl_twist_col;
-#endif
 	int			suspended;	/* 0 = normal  1 = suspended */
 #ifdef DEVICE_POLLING
 	int			rxcycles;


More information about the svn-src-all mailing list