PERFORCE change 109495 for review

Sam Leffler sam at FreeBSD.org
Tue Nov 7 23:45:10 UTC 2006


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

Change 109495 by sam at sam_ebb on 2006/11/07 23:44:33

	Hack around locking issue with npe msg support: we cannot
	sleep in npe_tick waiting for the update stats msg reply
	so use the send+recv api's to send a request each tick
	and fetch the results on the next.  This works because we
	are the only thread (at the moment) that will use the npe
	msg api once the interface is up and running.  Long term
	we probably need to revise the msg support.

Affected files ...

.. //depot/projects/arm/src/sys/arm/xscale/ixp425/if_npe.c#13 edit

Differences ...

==== //depot/projects/arm/src/sys/arm/xscale/ixp425/if_npe.c#13 (text+ko) ====

@@ -646,22 +646,12 @@
 }
 
 static void
-npe_tick(void *xsc)
+npe_addstats(struct npe_softc *sc)
 {
 #define	MIBADD(x)	sc->mibdata.x += be32toh(ns->x)
-	struct npe_softc *sc = xsc;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct npestats *ns = sc->sc_stats;
 
-	NPE_ASSERT_LOCKED(sc);
-
-	NPE_UNLOCK(sc);			/* XXX */
-	npe_updatestats(sc);		/* update + clear stats */
-	NPE_LOCK(sc);
-
-	bus_dmamap_sync(sc->sc_stats_tag, sc->sc_stats_map,
-		BUS_DMASYNC_POSTREAD);
-
 	MIBADD(dot3StatsAlignmentErrors);
 	MIBADD(dot3StatsFCSErrors);
 	MIBADD(dot3StatsSingleCollisionFrames);
@@ -682,7 +672,8 @@
 	      be32toh(ns->RxOverrunDiscards)
 	    + be32toh(ns->RxUnderflowEntryDiscards);
 
-	ifp->if_oerrors += be32toh(ns->dot3StatsInternalMacTransmitErrors)
+	ifp->if_oerrors +=
+		  be32toh(ns->dot3StatsInternalMacTransmitErrors)
 		+ be32toh(ns->TxVLANIdFilterDiscards)
 		;
 	ifp->if_ierrors += be32toh(ns->dot3StatsFCSErrors)
@@ -690,13 +681,31 @@
 		+ be32toh(ns->RxOverrunDiscards)
 		+ be32toh(ns->RxUnderflowEntryDiscards)
 		;
-	ifp->if_collisions += be32toh(ns->dot3StatsSingleCollisionFrames)
+	ifp->if_collisions +=
+		  be32toh(ns->dot3StatsSingleCollisionFrames)
 		+ be32toh(ns->dot3StatsMultipleCollisionFrames)
 		;
+#undef MIBADD
+}
 
+static void
+npe_tick(void *xsc)
+{
+#define	ACK	(NPE_RESETSTATS << NPE_MAC_MSGID_SHL)
+	struct npe_softc *sc = xsc;
+	uint32_t msg[2];
+
+	NPE_ASSERT_LOCKED(sc);
+
+	if (ixpnpe_recvmsg(sc->sc_npe, msg) == 0 && msg[0] == ACK) {
+		bus_dmamap_sync(sc->sc_stats_tag, sc->sc_stats_map,
+		    BUS_DMASYNC_POSTREAD);
+		npe_addstats(sc);
+	}
+	npe_updatestats(sc);
 	/* schedule next poll */
 	callout_reset(&sc->tick_ch, hz, npe_tick, sc);
-#undef MIBADD
+#undef ACK
 }
 
 static void
@@ -1238,7 +1247,7 @@
 
 	msg[0] = NPE_RESETSTATS << NPE_MAC_MSGID_SHL;
 	msg[1] = sc->sc_stats_phys;	/* physical address of stat block */
-	return ixpnpe_sendandrecvmsg(sc->sc_npe, msg, msg);
+	return ixpnpe_sendmsg(sc->sc_npe, msg);		/* NB: no recv */
 }
 
 #if 0


More information about the p4-projects mailing list