From owner-svn-src-head@FreeBSD.ORG Wed Sep 24 11:58:24 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6A25D669; Wed, 24 Sep 2014 11:58:24 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5514EE3C; Wed, 24 Sep 2014 11:58:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8OBwOB8039472; Wed, 24 Sep 2014 11:58:24 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8OBwObo039471; Wed, 24 Sep 2014 11:58:24 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201409241158.s8OBwObo039471@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 24 Sep 2014 11:58:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272067 - head/sys/dev/txp X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Sep 2014 11:58:24 -0000 Author: glebius Date: Wed Sep 24 11:58:23 2014 New Revision: 272067 URL: http://svnweb.freebsd.org/changeset/base/272067 Log: - Provide txp_get_counter() to return counters that are not collected, but taken from hardware. - Mechanically convert to if_inc_counter() the rest of counters. Modified: head/sys/dev/txp/if_txp.c Modified: head/sys/dev/txp/if_txp.c ============================================================================== --- head/sys/dev/txp/if_txp.c Wed Sep 24 11:33:43 2014 (r272066) +++ head/sys/dev/txp/if_txp.c Wed Sep 24 11:58:23 2014 (r272067) @@ -149,6 +149,7 @@ static int txp_intr(void *); static void txp_int_task(void *, int); static void txp_tick(void *); static int txp_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t txp_get_counter(struct ifnet *, ift_counter); static void txp_start(struct ifnet *); static void txp_start_locked(struct ifnet *); static int txp_encap(struct txp_softc *, struct txp_tx_ring *, struct mbuf **); @@ -413,6 +414,7 @@ txp_attach(device_t dev) ifp->if_ioctl = txp_ioctl; ifp->if_start = txp_start; ifp->if_init = txp_init; + ifp->if_get_counter = txp_get_counter; ifp->if_snd.ifq_drv_maxlen = TX_ENTRIES - 1; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); IFQ_SET_READY(&ifp->if_snd); @@ -2540,7 +2542,7 @@ txp_watchdog(struct txp_softc *sc) ifp = sc->sc_ifp; if_printf(ifp, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); txp_stop(sc); txp_init_locked(sc); } @@ -2816,13 +2818,11 @@ out: static void txp_stats_update(struct txp_softc *sc, struct txp_rsp_desc *rsp) { - struct ifnet *ifp; struct txp_hw_stats *ostats, *stats; struct txp_ext_desc *ext; TXP_LOCK_ASSERT(sc); - ifp = sc->sc_ifp; ext = (struct txp_ext_desc *)(rsp + 1); ostats = &sc->sc_ostats; stats = &sc->sc_stats; @@ -2856,15 +2856,34 @@ txp_stats_update(struct txp_softc *sc, s le32toh(ext[4].ext_3); stats->rx_oflows = ostats->rx_oflows + le32toh(ext[4].ext_4); stats->rx_filtered = ostats->rx_filtered + le32toh(ext[5].ext_1); +} - ifp->if_ierrors = stats->rx_fifo_oflows + stats->rx_badssd + - stats->rx_crcerrs + stats->rx_lenerrs + stats->rx_oflows; - ifp->if_oerrors = stats->tx_deferred + stats->tx_carrier_lost + - stats->tx_fifo_underruns + stats->tx_mcast_oflows; - ifp->if_collisions = stats->tx_late_colls + stats->tx_multi_colls + - stats->tx_excess_colls; - ifp->if_opackets = stats->tx_frames; - ifp->if_ipackets = stats->rx_frames; +static uint64_t +txp_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct txp_softc *sc; + struct txp_hw_stats *stats; + + sc = if_getsoftc(ifp); + stats = &sc->sc_stats; + + switch (cnt) { + case IFCOUNTER_IERRORS: + return (stats->rx_fifo_oflows + stats->rx_badssd + + stats->rx_crcerrs + stats->rx_lenerrs + stats->rx_oflows); + case IFCOUNTER_OERRORS: + return (stats->tx_deferred + stats->tx_carrier_lost + + stats->tx_fifo_underruns + stats->tx_mcast_oflows); + case IFCOUNTER_COLLISIONS: + return (stats->tx_late_colls + stats->tx_multi_colls + + stats->tx_excess_colls); + case IFCOUNTER_OPACKETS: + return (stats->tx_frames); + case IFCOUNTER_IPACKETS: + return (stats->rx_frames); + default: + return (if_get_counter_default(ifp, cnt)); + } } #define TXP_SYSCTL_STAT_ADD32(c, h, n, p, d) \