svn commit: r272241 - head/sys/dev/ixgb
Gleb Smirnoff
glebius at FreeBSD.org
Sun Sep 28 07:40:27 UTC 2014
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.
More information about the svn-src-all
mailing list