Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Sep 2014 20:15:53 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r271807 - head/sys/dev/fe
Message-ID:  <201409182015.s8IKFrfj038439@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Thu Sep 18 20:15:53 2014
New Revision: 271807
URL: http://svnweb.freebsd.org/changeset/base/271807

Log:
  Mechanically convert to if_inc_counter().

Modified:
  head/sys/dev/fe/if_fe.c

Modified: head/sys/dev/fe/if_fe.c
==============================================================================
--- head/sys/dev/fe/if_fe.c	Thu Sep 18 20:11:28 2014	(r271806)
+++ head/sys/dev/fe/if_fe.c	Thu Sep 18 20:15:53 2014	(r271807)
@@ -930,7 +930,7 @@ static void
 fe_reset (struct fe_softc *sc)
 {
 	/* Record how many packets are lost by this accident.  */
-	sc->ifp->if_oerrors += sc->txb_sched + sc->txb_count;
+	if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, sc->txb_sched + sc->txb_count);
 	sc->mibdata.dot3StatsInternalMacTransmitErrors++;
 
 	/* Put the interface into known initial state.  */
@@ -997,12 +997,15 @@ fe_watchdog (void *arg)
 	FE_ASSERT_LOCKED(sc);
 
 	if (sc->tx_timeout && --sc->tx_timeout == 0) {
+		struct ifnet *ifp = sc->ifp;
+
 		/* A "debug" message.  */
-		if_printf(sc->ifp, "transmission timeout (%d+%d)%s\n",
+		if_printf(ifp, "transmission timeout (%d+%d)%s\n",
 		    sc->txb_sched, sc->txb_count,
-		    (sc->ifp->if_flags & IFF_UP) ? "" : " when down");
-		if (sc->ifp->if_opackets == 0 && sc->ifp->if_ipackets == 0)
-			if_printf(sc->ifp, "wrong IRQ setting in config?\n");
+		    (ifp->if_flags & IFF_UP) ? "" : " when down");
+		if (ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS) == 0 &&
+		    ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS) == 0)
+			if_printf(ifp, "wrong IRQ setting in config?\n");
 		fe_reset(sc);
 	}
 	callout_reset(&sc->timer, hz, fe_watchdog, sc);
@@ -1519,7 +1522,7 @@ fe_tint (struct fe_softc * sc, u_char ts
 				 */
 				col = 1;
 			}
-			sc->ifp->if_collisions += col;
+			if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, col);
 			if (col == 1)
 				sc->mibdata.dot3StatsSingleCollisionFrames++;
 			else
@@ -1532,9 +1535,9 @@ fe_tint (struct fe_softc * sc, u_char ts
 		 * Be sure to reflect number of excessive collisions.
 		 */
 		col = sc->tx_excolls;
-		sc->ifp->if_opackets += sc->txb_sched - col;
-		sc->ifp->if_oerrors += col;
-		sc->ifp->if_collisions += col * 16;
+		if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, sc->txb_sched - col);
+		if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, col);
+		if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, col * 16);
 		sc->mibdata.dot3StatsExcessiveCollisions += col;
 		sc->mibdata.dot3StatsCollFrequencies[15] += col;
 		sc->txb_sched = 0;
@@ -1591,7 +1594,7 @@ fe_rint (struct fe_softc * sc, u_char rs
 		if (rstat & FE_D1_SRTPKT)
 			sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */
 #endif
-		sc->ifp->if_ierrors++;
+		if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1);
 	}
 
 	/*
@@ -1651,7 +1654,7 @@ fe_rint (struct fe_softc * sc, u_char rs
 		    len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
 			if_printf(sc->ifp,
 			    "RX buffer out-of-sync\n");
-			sc->ifp->if_ierrors++;
+			if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1);
 			sc->mibdata.dot3StatsInternalMacReceiveErrors++;
 			fe_reset(sc);
 			return;
@@ -1668,14 +1671,14 @@ fe_rint (struct fe_softc * sc, u_char rs
 			 * in the buffer.  We hope we can get more
 			 * mbuf next time.
 			 */
-			sc->ifp->if_ierrors++;
+			if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1);
 			sc->mibdata.dot3StatsMissedFrames++;
 			fe_droppacket(sc, len);
 			return;
 		}
 
 		/* Successfully received a packet.  Update stat.  */
-		sc->ifp->if_ipackets++;
+		if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1);
 	}
 
 	/* Maximum number of frames has been received.  Something
@@ -1961,7 +1964,7 @@ fe_write_mbufs (struct fe_softc *sc, str
 	    length > ETHER_MAX_LEN - ETHER_CRC_LEN) {
 		if_printf(sc->ifp,
 		    "got an out-of-spec packet (%u bytes) to send\n", length);
-		sc->ifp->if_oerrors++;
+		if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
 		sc->mibdata.dot3StatsInternalMacTransmitErrors++;
 		return;
 	}



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