svn commit: r251830 - stable/8/sys/dev/fxp

Pyun YongHyeon yongari at FreeBSD.org
Mon Jun 17 04:42:02 UTC 2013


Author: yongari
Date: Mon Jun 17 04:42:02 2013
New Revision: 251830
URL: http://svnweb.freebsd.org/changeset/base/251830

Log:
  MFC r251600:
    Avoid unnecessary controller reinitialization by checking driver
    running state.  fxp(4) requires controller reinitialization for the
    following cases.
     o RX lockup condition on i82557
     o promiscuous mode change
     o multicast filter change
     o WOL configuration
     o TSO/VLAN hardware tagging/checksum offloading configuration
     o MAC reprogramming after speed/duplex/flow-control resolution
     o Any events that result in MAC reprogramming(link UP/DOWN,
       remote link partner's restart of auto-negotiation etc)
     o Microcode loading/unloading
    Apart from above cases which come from hardware limitation, upper
    stack also blindly reinitializes controller whenever an IP address
    is assigned. After r194573, fxp(4) no longer needs to reinitialize
    the controller to program multicast filter after upping the
    interface. So keeping track of driver running state should remove
    all unnecessary controller reinitializations.
  
    This change will also address endless controller reinitialization
    triggered by dhclient(8).

Modified:
  stable/8/sys/dev/fxp/if_fxp.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/fxp/   (props changed)

Modified: stable/8/sys/dev/fxp/if_fxp.c
==============================================================================
--- stable/8/sys/dev/fxp/if_fxp.c	Mon Jun 17 04:40:27 2013	(r251829)
+++ stable/8/sys/dev/fxp/if_fxp.c	Mon Jun 17 04:42:02 2013	(r251830)
@@ -1074,7 +1074,8 @@ fxp_suspend(device_t dev)
 			pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
 			sc->flags |= FXP_FLAG_WOL;
 			/* Reconfigure hardware to accept magic frames. */
-			fxp_init_body(sc, 1);
+			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+			fxp_init_body(sc, 0);
 		}
 		pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
 	}
@@ -2140,8 +2141,10 @@ fxp_tick(void *xsc)
 	 */
 	if (sc->rx_idle_secs > FXP_MAX_RX_IDLE) {
 		sc->rx_idle_secs = 0;
-		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
+			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 			fxp_init_body(sc, 1);
+		}
 		return;
 	}
 	/*
@@ -2239,6 +2242,7 @@ fxp_watchdog(struct fxp_softc *sc)
 	device_printf(sc->dev, "device timeout\n");
 	sc->ifp->if_oerrors++;
 
+	sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 	fxp_init_body(sc, 1);
 }
 
@@ -2273,6 +2277,10 @@ fxp_init_body(struct fxp_softc *sc, int 
 	int i, prm;
 
 	FXP_LOCK_ASSERT(sc, MA_OWNED);
+
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+		return;
+
 	/*
 	 * Cancel any pending I/O
 	 */
@@ -2812,6 +2820,7 @@ fxp_miibus_statchg(device_t dev)
 	 */
 	if (sc->revision == FXP_REV_82557)
 		return;
+	ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 	fxp_init_body(sc, 0);
 }
 
@@ -2835,9 +2844,10 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 		if (ifp->if_flags & IFF_UP) {
 			if (((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) &&
 			    ((ifp->if_flags ^ sc->if_flags) &
-			    (IFF_PROMISC | IFF_ALLMULTI | IFF_LINK0)) != 0)
+			    (IFF_PROMISC | IFF_ALLMULTI | IFF_LINK0)) != 0) {
+				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 				fxp_init_body(sc, 0);
-			else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+			} else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
 				fxp_init_body(sc, 1);
 		} else {
 			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
@@ -2850,8 +2860,10 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 	case SIOCADDMULTI:
 	case SIOCDELMULTI:
 		FXP_LOCK(sc);
-		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
+			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 			fxp_init_body(sc, 0);
+		}
 		FXP_UNLOCK(sc);
 		break;
 
@@ -2941,8 +2953,10 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 				    ~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
 			reinit++;
 		}
-		if (reinit > 0 && ifp->if_flags & IFF_UP)
+		if (reinit > 0 && (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
+			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 			fxp_init_body(sc, 0);
+		}
 		FXP_UNLOCK(sc);
 		VLAN_CAPABILITIES(ifp);
 		break;


More information about the svn-src-stable-8 mailing list