From owner-p4-projects@FreeBSD.ORG Tue Nov 7 23:45:10 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 53A7D16A417; Tue, 7 Nov 2006 23:45:10 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D7D916A40F for ; Tue, 7 Nov 2006 23:45:10 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 33F9543D5D for ; Tue, 7 Nov 2006 23:45:05 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kA7Nj5EI083169 for ; Tue, 7 Nov 2006 23:45:05 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kA7Nj5Fa083166 for perforce@freebsd.org; Tue, 7 Nov 2006 23:45:05 GMT (envelope-from sam@freebsd.org) Date: Tue, 7 Nov 2006 23:45:05 GMT Message-Id: <200611072345.kA7Nj5Fa083166@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 109495 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Nov 2006 23:45:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=109495 Change 109495 by sam@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