From owner-svn-src-all@FreeBSD.ORG Sun Sep 28 07:40:27 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 92FAF456; Sun, 28 Sep 2014 07:40:27 +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 748AAF30; Sun, 28 Sep 2014 07:40:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8S7eRhW073744; Sun, 28 Sep 2014 07:40:27 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8S7eRbF073742; Sun, 28 Sep 2014 07:40:27 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201409280740.s8S7eRbF073742@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sun, 28 Sep 2014 07:40:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272241 - head/sys/dev/ixgb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Sep 2014 07:40:27 -0000 Author: glebius Date: Sun Sep 28 07:40:26 2014 New Revision: 272241 URL: http://svnweb.freebsd.org/changeset/base/272241 Log: Provide ixgb_get_counter(). Modified: head/sys/dev/ixgb/if_ixgb.c Modified: head/sys/dev/ixgb/if_ixgb.c ============================================================================== --- head/sys/dev/ixgb/if_ixgb.c Sun Sep 28 07:29:45 2014 (r272240) +++ head/sys/dev/ixgb/if_ixgb.c Sun Sep 28 07:40:26 2014 (r272241) @@ -97,6 +97,7 @@ static void ixgb_intr(void *); static void ixgb_start(struct ifnet *); static void ixgb_start_locked(struct ifnet *); static int ixgb_ioctl(struct ifnet *, IOCTL_CMD_TYPE, caddr_t); +static uint64_t ixgb_get_counter(struct ifnet *, ift_counter); static void ixgb_watchdog(struct adapter *); static void ixgb_init(void *); static void ixgb_init_locked(struct adapter *); @@ -643,7 +644,7 @@ ixgb_watchdog(struct adapter *adapter) ixgb_init_locked(adapter); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } @@ -1355,6 +1356,7 @@ ixgb_setup_interface(device_t dev, struc ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixgb_ioctl; ifp->if_start = ixgb_start; + ifp->if_get_counter = ixgb_get_counter; ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1; #if __FreeBSD_version < 500000 @@ -2326,7 +2328,6 @@ ixgb_write_pci_cfg(struct ixgb_hw * hw, static void ixgb_update_stats_counters(struct adapter * adapter) { - struct ifnet *ifp; adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS); adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL); @@ -2389,29 +2390,37 @@ ixgb_update_stats_counters(struct adapte adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC); adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC); adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC); +} - ifp = adapter->ifp; - - /* Fill out the OS statistics structure */ - ifp->if_ipackets = adapter->stats.gprcl; - ifp->if_opackets = adapter->stats.gptcl; - ifp->if_ibytes = adapter->stats.gorcl; - ifp->if_obytes = adapter->stats.gotcl; - ifp->if_imcasts = adapter->stats.mprcl; - ifp->if_collisions = 0; - - /* Rx Errors */ - ifp->if_ierrors = - adapter->dropped_pkts + - adapter->stats.crcerrs + - adapter->stats.rnbc + - adapter->stats.mpc + - adapter->stats.rlec; +static uint64_t +ixgb_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct adapter *adapter; + adapter = if_getsoftc(ifp); + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (adapter->stats.gprcl); + case IFCOUNTER_OPACKETS: + return ( adapter->stats.gptcl); + case IFCOUNTER_IBYTES: + return (adapter->stats.gorcl); + case IFCOUNTER_OBYTES: + return (adapter->stats.gotcl); + case IFCOUNTER_IMCASTS: + return ( adapter->stats.mprcl); + case IFCOUNTER_COLLISIONS: + return (0); + case IFCOUNTER_IERRORS: + return (adapter->dropped_pkts + adapter->stats.crcerrs + + adapter->stats.rnbc + adapter->stats.mpc + + adapter->stats.rlec); + default: + return (if_get_counter_default(ifp, cnt)); + } } - /********************************************************************** * * This routine is called only when ixgb_display_debug_stats is enabled.