From 058a38660ec7904d08543644c634e634d3ec1196 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Sun, 28 Sep 2014 07:29:45 +0000 Subject: Convert to if_get_counter(). --- sys/dev/ixgbe/ixgbe.c | 52 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'sys/dev/ixgbe/ixgbe.c') diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 279dac2ceeb4..d7371a861c33 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -120,6 +120,7 @@ static int ixgbe_ioctl(struct ifnet *, u_long, caddr_t); static void ixgbe_init(void *); static void ixgbe_init_locked(struct adapter *); static void ixgbe_stop(void *); +static uint64_t ixgbe_get_counter(struct ifnet *, ift_counter); static void ixgbe_media_status(struct ifnet *, struct ifmediareq *); static int ixgbe_media_change(struct ifnet *); static void ixgbe_identify_hardware(struct adapter *); @@ -2721,6 +2722,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter) ifp->if_softc = adapter; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixgbe_ioctl; + ifp->if_get_counter = ixgbe_get_counter; #ifndef IXGBE_LEGACY_TX ifp->if_transmit = ixgbe_mq_start; ifp->if_qflush = ixgbe_qflush; @@ -5364,10 +5366,8 @@ ixgbe_reinit_fdir(void *context, int pending) static void ixgbe_update_stats_counters(struct adapter *adapter) { - struct ifnet *ifp = adapter->ifp; struct ixgbe_hw *hw = &adapter->hw; u32 missed_rx = 0, bprc, lxon, lxoff, total; - u64 total_missed_rx = 0; adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); adapter->stats.illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC); @@ -5386,8 +5386,6 @@ ixgbe_update_stats_counters(struct adapter *adapter) missed_rx += mp; /* global total per queue */ adapter->stats.mpc[i] += mp; - /* Running comprehensive total for stats display */ - total_missed_rx += adapter->stats.mpc[i]; if (hw->mac.type == ixgbe_mac_82598EB) { adapter->stats.rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); @@ -5497,19 +5495,41 @@ ixgbe_update_stats_counters(struct adapter *adapter) adapter->stats.fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC); adapter->stats.fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); } +} - /* Fill out the OS statistics structure */ - ifp->if_ipackets = adapter->stats.gprc; - ifp->if_opackets = adapter->stats.gptc; - ifp->if_ibytes = adapter->stats.gorc; - ifp->if_obytes = adapter->stats.gotc; - ifp->if_imcasts = adapter->stats.mprc; - ifp->if_omcasts = adapter->stats.mptc; - ifp->if_collisions = 0; - - /* Rx Errors */ - ifp->if_iqdrops = total_missed_rx; - ifp->if_ierrors = adapter->stats.crcerrs + adapter->stats.rlec; +static uint64_t +ixgbe_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct adapter *adapter; + uint64_t rv; + + adapter = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (adapter->stats.gprc); + case IFCOUNTER_OPACKETS: + return (adapter->stats.gptc); + case IFCOUNTER_IBYTES: + return (adapter->stats.gorc); + case IFCOUNTER_OBYTES: + return (adapter->stats.gotc); + case IFCOUNTER_IMCASTS: + return (adapter->stats.mprc); + case IFCOUNTER_OMCASTS: + return (adapter->stats.mptc); + case IFCOUNTER_COLLISIONS: + return (0); + case IFCOUNTER_IQDROPS: + rv = 0; + for (int i = 0; i < 8; i++) + rv += adapter->stats.mpc[i]; + return (rv); + case IFCOUNTER_IERRORS: + return (adapter->stats.crcerrs + adapter->stats.rlec); + default: + return (if_get_counter_default(ifp, cnt)); + } } /** ixgbe_sysctl_tdh_handler - Handler function -- cgit v1.2.3