Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jan 2012 18:21:18 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r229607 - stable/9/sys/dev/vr
Message-ID:  <201201051821.q05ILI2N048322@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Thu Jan  5 18:21:17 2012
New Revision: 229607
URL: http://svn.freebsd.org/changeset/base/229607

Log:
  MFC r228084:
    Reuse flag variable to represent driver internal states rather than
    using member variables in softc.
    While I'm here change media after setting IFF_DRV_RUNNING. This
    will remove unnecessary link state handling in vr_tick() if
    controller established a link immediately.

Modified:
  stable/9/sys/dev/vr/if_vr.c
  stable/9/sys/dev/vr/if_vrreg.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)

Modified: stable/9/sys/dev/vr/if_vr.c
==============================================================================
--- stable/9/sys/dev/vr/if_vr.c	Thu Jan  5 17:30:15 2012	(r229606)
+++ stable/9/sys/dev/vr/if_vr.c	Thu Jan  5 18:21:17 2012	(r229607)
@@ -305,20 +305,20 @@ vr_miibus_statchg(device_t dev)
 	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
 		return;
 
-	sc->vr_link = 0;
+	sc->vr_flags &= ~VR_F_LINK;
 	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
 	    (IFM_ACTIVE | IFM_AVALID)) {
 		switch (IFM_SUBTYPE(mii->mii_media_active)) {
 		case IFM_10_T:
 		case IFM_100_TX:
-			sc->vr_link = 1;
+			sc->vr_flags |= VR_F_LINK;
 			break;
 		default:
 			break;
 		}
 	}
 
-	if (sc->vr_link != 0) {
+	if ((sc->vr_flags & VR_F_LINK) != 0) {
 		cr0 = CSR_READ_1(sc, VR_CR0);
 		cr1 = CSR_READ_1(sc, VR_CR1);
 		mfdx = (cr1 & VR_CR1_FULLDUPLEX) != 0;
@@ -821,7 +821,7 @@ vr_detach(device_t dev)
 	/* These should only be active if attach succeeded. */
 	if (device_is_attached(dev)) {
 		VR_LOCK(sc);
-		sc->vr_detach = 1;
+		sc->vr_flags |= VR_F_DETACHED;
 		vr_stop(sc);
 		VR_UNLOCK(sc);
 		callout_drain(&sc->vr_stat_callout);
@@ -1542,7 +1542,7 @@ vr_tick(void *xsc)
 
 	mii = device_get_softc(sc->vr_miibus);
 	mii_tick(mii);
-	if (sc->vr_link == 0)
+	if ((sc->vr_flags & VR_F_LINK) == 0)
 		vr_miibus_statchg(sc->vr_dev);
 	vr_watchdog(sc);
 	callout_reset(&sc->vr_stat_callout, hz, vr_tick, sc);
@@ -1652,7 +1652,7 @@ vr_intr(void *arg)
 
 	VR_LOCK(sc);
 
-	if (sc->vr_suspended != 0)
+	if ((sc->vr_flags & VR_F_SUSPENDED) != 0)
 		goto done_locked;
 
 	status = CSR_READ_2(sc, VR_ISR);
@@ -1933,7 +1933,7 @@ vr_start_locked(struct ifnet *ifp)
 	VR_LOCK_ASSERT(sc);
 
 	if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
-	    IFF_DRV_RUNNING || sc->vr_link == 0)
+	    IFF_DRV_RUNNING || (sc->vr_flags & VR_F_LINK) == 0)
 		return;
 
 	for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
@@ -2103,12 +2103,12 @@ vr_init_locked(struct vr_softc *sc)
 	if (sc->vr_revid > REV_ID_VT6102_A)
 		CSR_WRITE_2(sc, VR_MII_IMR, 0);
 
-	sc->vr_link = 0;
-	mii_mediachg(mii);
-
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 
+	sc->vr_flags &= ~VR_F_LINK;
+	mii_mediachg(mii);
+
 	callout_reset(&sc->vr_stat_callout, hz, vr_tick, sc);
 }
 
@@ -2177,7 +2177,7 @@ vr_ioctl(struct ifnet *ifp, u_long comma
 				    (IFF_PROMISC | IFF_ALLMULTI))
 					vr_set_filter(sc);
 			} else {
-				if (sc->vr_detach == 0)
+				if ((sc->vr_flags & VR_F_DETACHED) == 0)
 					vr_init_locked(sc);
 			}
 		} else {
@@ -2265,7 +2265,7 @@ vr_watchdog(struct vr_softc *sc)
 	if (sc->vr_cdata.vr_tx_cnt == 0)
 		return;
 
-	if (sc->vr_link == 0) {
+	if ((sc->vr_flags & VR_F_LINK) == 0) {
 		if (bootverbose)
 			if_printf(sc->vr_ifp, "watchdog timeout "
 			   "(missed link)\n");
@@ -2443,7 +2443,7 @@ vr_suspend(device_t dev)
 	VR_LOCK(sc);
 	vr_stop(sc);
 	vr_setwol(sc);
-	sc->vr_suspended = 1;
+	sc->vr_flags |= VR_F_SUSPENDED;
 	VR_UNLOCK(sc);
 
 	return (0);
@@ -2464,7 +2464,7 @@ vr_resume(device_t dev)
 	if (ifp->if_flags & IFF_UP)
 		vr_init_locked(sc);
 
-	sc->vr_suspended = 0;
+	sc->vr_flags &= ~VR_F_SUSPENDED;
 	VR_UNLOCK(sc);
 
 	return (0);

Modified: stable/9/sys/dev/vr/if_vrreg.h
==============================================================================
--- stable/9/sys/dev/vr/if_vrreg.h	Thu Jan  5 17:30:15 2012	(r229606)
+++ stable/9/sys/dev/vr/if_vrreg.h	Thu Jan  5 18:21:17 2012	(r229607)
@@ -720,20 +720,20 @@ struct vr_softc {
 	void			*vr_intrhand;
 	device_t		vr_miibus;
 	uint8_t			vr_revid;	/* Rhine chip revision */
-	uint8_t			vr_flags;	/* See VR_F_* below */
-#define	VR_F_RESTART		0x01		/* Restart unit on next tick */
+	int			vr_flags;	/* See VR_F_* below */
+#define	VR_F_RESTART		0x0001		/* Restart unit on next tick */
+#define	VR_F_SUSPENDED		0x2000
+#define	VR_F_DETACHED		0x4000
+#define	VR_F_LINK		0x8000
 	int			vr_if_flags;
 	struct vr_chain_data	vr_cdata;
 	struct vr_ring_data	vr_rdata;
 	struct vr_statistics	vr_stat;
 	struct callout		vr_stat_callout;
 	struct mtx		vr_mtx;
-	int			vr_suspended;	/* if 1, sleeping/detaching */
 	int			vr_quirks;
-	int			vr_link;
 	int			vr_watchdog_timer;
 	int			vr_txthresh;
-	int			vr_detach;
 #ifdef DEVICE_POLLING
 	int			rxcycles;
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201051821.q05ILI2N048322>