Date: Thu, 25 Sep 2014 08:36:12 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272099 - head/sys/dev/vmware/vmxnet3 Message-ID: <201409250836.s8P8aCLu029959@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Thu Sep 25 08:36:11 2014 New Revision: 272099 URL: http://svnweb.freebsd.org/changeset/base/272099 Log: Provide vmxnet3_get_counter() to return counters that are not collected, but taken from hardware. Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c ============================================================================== --- head/sys/dev/vmware/vmxnet3/if_vmx.c Thu Sep 25 08:28:10 2014 (r272098) +++ head/sys/dev/vmware/vmxnet3/if_vmx.c Thu Sep 25 08:36:11 2014 (r272099) @@ -187,6 +187,7 @@ static void vmxnet3_unregister_vlan(void static void vmxnet3_set_rxfilter(struct vmxnet3_softc *); static int vmxnet3_change_mtu(struct vmxnet3_softc *, int); static int vmxnet3_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t vmxnet3_get_counter(struct ifnet *, ift_counter); #ifndef VMXNET3_LEGACY_TX static void vmxnet3_qflush(struct ifnet *); @@ -194,10 +195,6 @@ static void vmxnet3_qflush(struct ifnet static int vmxnet3_watchdog(struct vmxnet3_txqueue *); static void vmxnet3_refresh_host_stats(struct vmxnet3_softc *); -static void vmxnet3_txq_accum_stats(struct vmxnet3_txqueue *, - struct vmxnet3_txq_stats *); -static void vmxnet3_rxq_accum_stats(struct vmxnet3_rxqueue *, - struct vmxnet3_rxq_stats *); static void vmxnet3_tick(void *); static void vmxnet3_link_status(struct vmxnet3_softc *); static void vmxnet3_media_status(struct ifnet *, struct ifmediareq *); @@ -1722,6 +1719,7 @@ vmxnet3_setup_interface(struct vmxnet3_s ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = vmxnet3_init; ifp->if_ioctl = vmxnet3_ioctl; + ifp->if_get_counter = vmxnet3_get_counter; ifp->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); ifp->if_hw_tsomaxsegcount = VMXNET3_TX_MAXSEGS; ifp->if_hw_tsomaxsegsize = VMXNET3_TX_MAXSEGSIZE; @@ -3344,56 +3342,14 @@ vmxnet3_refresh_host_stats(struct vmxnet vmxnet3_write_cmd(sc, VMXNET3_CMD_GET_STATS); } -static void -vmxnet3_txq_accum_stats(struct vmxnet3_txqueue *txq, - struct vmxnet3_txq_stats *accum) -{ - struct vmxnet3_txq_stats *st; - - st = &txq->vxtxq_stats; - - accum->vmtxs_opackets += st->vmtxs_opackets; - accum->vmtxs_obytes += st->vmtxs_obytes; - accum->vmtxs_omcasts += st->vmtxs_omcasts; - accum->vmtxs_csum += st->vmtxs_csum; - accum->vmtxs_tso += st->vmtxs_tso; - accum->vmtxs_full += st->vmtxs_full; - accum->vmtxs_offload_failed += st->vmtxs_offload_failed; -} - -static void -vmxnet3_rxq_accum_stats(struct vmxnet3_rxqueue *rxq, - struct vmxnet3_rxq_stats *accum) +static uint64_t +vmxnet3_get_counter(struct ifnet *ifp, ift_counter cnt) { - struct vmxnet3_rxq_stats *st; - - st = &rxq->vxrxq_stats; - - accum->vmrxs_ipackets += st->vmrxs_ipackets; - accum->vmrxs_ibytes += st->vmrxs_ibytes; - accum->vmrxs_iqdrops += st->vmrxs_iqdrops; - accum->vmrxs_ierrors += st->vmrxs_ierrors; -} - -static void -vmxnet3_accumulate_stats(struct vmxnet3_softc *sc) -{ - struct ifnet *ifp; - struct vmxnet3_statistics *st; - struct vmxnet3_txq_stats txaccum; - struct vmxnet3_rxq_stats rxaccum; - int i; - - ifp = sc->vmx_ifp; - st = &sc->vmx_stats; - - bzero(&txaccum, sizeof(struct vmxnet3_txq_stats)); - bzero(&rxaccum, sizeof(struct vmxnet3_rxq_stats)); + struct vmxnet3_softc *sc; + uint64_t rv; - for (i = 0; i < sc->vmx_ntxqueues; i++) - vmxnet3_txq_accum_stats(&sc->vmx_txq[i], &txaccum); - for (i = 0; i < sc->vmx_nrxqueues; i++) - vmxnet3_rxq_accum_stats(&sc->vmx_rxq[i], &rxaccum); + sc = if_getsoftc(ifp); + rv = 0; /* * With the exception of if_ierrors, these ifnet statistics are @@ -3401,14 +3357,36 @@ vmxnet3_accumulate_stats(struct vmxnet3_ * values. if_ierrors is updated in ether_input() for malformed * frames that we should have already discarded. */ - ifp->if_ipackets = rxaccum.vmrxs_ipackets; - ifp->if_iqdrops = rxaccum.vmrxs_iqdrops; - ifp->if_ierrors = rxaccum.vmrxs_ierrors; - ifp->if_opackets = txaccum.vmtxs_opackets; + switch (cnt) { + case IFCOUNTER_IPACKETS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets; + return (rv); + case IFCOUNTER_IQDROPS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops; + return (rv); + case IFCOUNTER_IERRORS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors; + return (rv); + case IFCOUNTER_OPACKETS: + for (int i = 0; i < sc->vmx_ntxqueues; i++) + rv += sc->vmx_txq[i].vxtxq_stats.vmtxs_opackets; + return (rv); #ifndef VMXNET3_LEGACY_TX - ifp->if_obytes = txaccum.vmtxs_obytes; - ifp->if_omcasts = txaccum.vmtxs_omcasts; + case IFCOUNTER_OBYTES: + for (int i = 0; i < sc->vmx_ntxqueues; i++) + rv += sc->vmx_txq[i].vxtxq_stats.vmtxs_obytes; + return (rv); + case IFCOUNTER_OMCASTS: + for (int i = 0; i < sc->vmx_ntxqueues; i++) + rv += sc->vmx_txq[i].vxtxq_stats.vmtxs_omcasts; + return (rv); #endif + default: + return (if_get_counter_default(ifp, cnt)); + } } static void @@ -3424,7 +3402,6 @@ vmxnet3_tick(void *xsc) VMXNET3_CORE_LOCK_ASSERT(sc); - vmxnet3_accumulate_stats(sc); vmxnet3_refresh_host_stats(sc); for (i = 0; i < sc->vmx_ntxqueues; i++)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409250836.s8P8aCLu029959>