From owner-svn-src-head@FreeBSD.ORG Thu Sep 25 07:00:32 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 744AFE65; Thu, 25 Sep 2014 07:00:32 +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 5F5A3C0A; Thu, 25 Sep 2014 07:00:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8P70WOG082716; Thu, 25 Sep 2014 07:00:32 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8P70W5H082715; Thu, 25 Sep 2014 07:00:32 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201409250700.s8P70W5H082715@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 25 Sep 2014 07:00:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272095 - head/sys/dev/lmc 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: Thu, 25 Sep 2014 07:00:32 -0000 Author: glebius Date: Thu Sep 25 07:00:31 2014 New Revision: 272095 URL: http://svnweb.freebsd.org/changeset/base/272095 Log: - Provide lmc_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/lmc/if_lmc.c Modified: head/sys/dev/lmc/if_lmc.c ============================================================================== --- head/sys/dev/lmc/if_lmc.c Thu Sep 25 06:47:38 2014 (r272094) +++ head/sys/dev/lmc/if_lmc.c Thu Sep 25 07:00:31 2014 (r272095) @@ -2602,7 +2602,7 @@ rxintr_cleanup(softc_t *sc) /* Include CRC and one flag byte in input byte count. */ sc->status.cntrs.ibytes += first_mbuf->m_pkthdr.len + sc->config.crc_len +1; sc->status.cntrs.ipackets++; - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); LMC_BPF_MTAP(first_mbuf); #if defined(DEVICE_POLLING) sc->quota--; @@ -2765,7 +2765,7 @@ txintr_cleanup(softc_t *sc) /* Include CRC and one flag byte in output byte count. */ sc->status.cntrs.obytes += m->m_pkthdr.len + sc->config.crc_len +1; sc->status.cntrs.opackets++; - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); LMC_BPF_MTAP(m); /* The only bad TX status is fifo underrun. */ if ((desc->status & TLP_DSTS_TX_UNDERRUN) != 0) @@ -3680,7 +3680,7 @@ lmc_raw_output(struct ifnet *ifp, struct { m_freem(m); sc->status.cntrs.odiscards++; - ifp->if_oqdrops++; + if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); if (DRIVER_DEBUG) printf("%s: lmc_raw_output: IFQ_ENQUEUE() failed; error %d\n", NAME_UNIT, error); @@ -3692,11 +3692,10 @@ lmc_raw_output(struct ifnet *ifp, struct /* Called from a softirq once a second. */ static void lmc_watchdog(void *arg) - { +{ struct ifnet *ifp = arg; softc_t *sc = IFP2SC(ifp); u_int8_t old_oper_status = sc->status.oper_status; - struct event_cntrs *cntrs = &sc->status.cntrs; core_watchdog(sc); /* updates oper_status */ @@ -3762,16 +3761,7 @@ lmc_watchdog(void *arg) # endif } - /* Copy statistics from sc to ifp. */ ifp->if_baudrate = sc->status.tx_speed; - ifp->if_ipackets = cntrs->ipackets; - ifp->if_opackets = cntrs->opackets; - ifp->if_ibytes = cntrs->ibytes; - ifp->if_obytes = cntrs->obytes; - ifp->if_ierrors = cntrs->ierrors; - ifp->if_oerrors = cntrs->oerrors; - ifp->if_iqdrops = cntrs->idiscards; - if (sc->status.oper_status == STATUS_UP) ifp->if_link_state = LINK_STATE_UP; else @@ -3779,8 +3769,36 @@ lmc_watchdog(void *arg) /* Call this procedure again after one second. */ callout_reset(&sc->callout, hz, lmc_watchdog, ifp); - } +} +static uint64_t +lmc_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + softc_t *sc; + struct event_cntrs *cntrs; + + sc = if_getsoftc(ifp); + cntrs = &sc->status.cntrs; + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (cntrs->ipackets); + case IFCOUNTER_OPACKETS: + return (cntrs->opackets); + case IFCOUNTER_IBYTES: + return (cntrs->ibytes); + case IFCOUNTER_OBYTES: + return (cntrs->obytes); + case IFCOUNTER_IERRORS: + return (cntrs->ierrors); + case IFCOUNTER_OERRORS: + return (cntrs->oerrors); + case IFCOUNTER_IQDROPS: + return (cntrs->idiscards); + default: + return (if_get_counter_default(ifp, cnt)); + } +} static void setup_ifnet(struct ifnet *ifp) @@ -3794,6 +3812,7 @@ setup_ifnet(struct ifnet *ifp) ifp->if_start = lmc_ifnet_start; /* sppp changes this */ ifp->if_output = lmc_raw_output; /* sppp & p2p change this */ ifp->if_input = lmc_raw_input; + ifp->if_get_counter = lmc_get_counter; ifp->if_mtu = MAX_DESC_LEN; /* sppp & p2p change this */ ifp->if_type = IFT_PTPSERIAL; /* p2p changes this */