From owner-svn-src-head@FreeBSD.ORG Thu Apr 30 18:23:40 2015 Return-Path: Delivered-To: svn-src-head@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 54DA3D93; Thu, 30 Apr 2015 18:23:40 +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 433801BC1; Thu, 30 Apr 2015 18:23:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3UINeIS073190; Thu, 30 Apr 2015 18:23:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3UINd74073186; Thu, 30 Apr 2015 18:23:39 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201504301823.t3UINd74073186@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 30 Apr 2015 18:23:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282280 - in head/sys/dev: e1000 ixgbe ixl 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.20 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, 30 Apr 2015 18:23:40 -0000 Author: jhb Date: Thu Apr 30 18:23:38 2015 New Revision: 282280 URL: https://svnweb.freebsd.org/changeset/base/282280 Log: Various fixes to the stats in igb(4), ixgbe(4), and ixl(4). - Use hardware counters for ifnet stats in igb(4) when possible. This ensures these stats include packets that bypass the regular stack via netmap. - Don't derefence values off the end of the igb(4) VF stats structure. Instead, add a dedicated if_get_counter method for igb(4) VF interfaces. - Report missed packets on igb(4) as input queue drops rather than an input error. - Report bug_ring drop counts as output queue drops for igb(4) and ixgbe(4). - Export the buf_ring drop stats for individual rings via sysctl on ixgbe(4). - Fix a typo that in ixl(4) that caused output queue drops to be reported as input queue drops and input queue drops to be unreported. Differential Revision: https://reviews.freebsd.org/D2402 Reviewed by: jfv, rstone (6) Sponsored by: Norse Corp, Inc. Modified: head/sys/dev/e1000/if_igb.c head/sys/dev/ixgbe/if_ix.c head/sys/dev/ixl/ixl.h Modified: head/sys/dev/e1000/if_igb.c ============================================================================== --- head/sys/dev/e1000/if_igb.c Thu Apr 30 18:11:43 2015 (r282279) +++ head/sys/dev/e1000/if_igb.c Thu Apr 30 18:23:38 2015 (r282280) @@ -1046,8 +1046,7 @@ igb_mq_start_locked(struct ifnet *ifp, s } drbr_advance(ifp, txr->br); enq++; - if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len); - if (next->m_flags & M_MCAST) + if (next->m_flags & M_MCAST && adapter->vf_ifp) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); ETHER_BPF_MTAP(ifp, next); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) @@ -4055,7 +4054,9 @@ static bool igb_txeof(struct tx_ring *txr) { struct adapter *adapter = txr->adapter; +#ifdef DEV_NETMAP struct ifnet *ifp = adapter->ifp; +#endif /* DEV_NETMAP */ u32 work, processed = 0; u16 limit = txr->process_limit; struct igb_tx_buf *buf; @@ -4130,7 +4131,6 @@ igb_txeof(struct tx_ring *txr) } ++txr->packets; ++processed; - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); txr->watchdog_time = ticks; /* Try the next packet */ @@ -5127,7 +5127,6 @@ igb_rxeof(struct igb_queue *que, int cou if (eop) { rxr->fmp->m_pkthdr.rcvif = ifp; - if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); rxr->rx_packets++; /* capture data for AIM */ rxr->packets++; @@ -5560,24 +5559,94 @@ igb_led_func(void *arg, int onoff) } static uint64_t +igb_get_vf_counter(if_t ifp, ift_counter cnt) +{ + struct adapter *adapter; + struct e1000_vf_stats *stats; +#ifndef IGB_LEGACY_TX + struct tx_ring *txr; + uint64_t rv; +#endif + + adapter = if_getsoftc(ifp); + stats = (struct e1000_vf_stats *)adapter->stats; + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (stats->gprc); + case IFCOUNTER_OPACKETS: + return (stats->gptc); + case IFCOUNTER_IBYTES: + return (stats->gorc); + case IFCOUNTER_OBYTES: + return (stats->gotc); + case IFCOUNTER_IMCASTS: + return (stats->mprc); + case IFCOUNTER_IERRORS: + return (adapter->dropped_pkts); + case IFCOUNTER_OERRORS: + return (adapter->watchdog_events); +#ifndef IGB_LEGACY_TX + case IFCOUNTER_OQDROPS: + rv = 0; + txr = adapter->tx_rings; + for (int i = 0; i < adapter->num_queues; i++, txr++) + rv += txr->br->br_drops; + return (rv); +#endif + default: + return (if_get_counter_default(ifp, cnt)); + } +} + +static uint64_t igb_get_counter(if_t ifp, ift_counter cnt) { struct adapter *adapter; struct e1000_hw_stats *stats; +#ifndef IGB_LEGACY_TX + struct tx_ring *txr; + uint64_t rv; +#endif adapter = if_getsoftc(ifp); + if (adapter->vf_ifp) + return (igb_get_vf_counter(ifp, cnt)); + stats = (struct e1000_hw_stats *)adapter->stats; switch (cnt) { + case IFCOUNTER_IPACKETS: + return (stats->gprc); + case IFCOUNTER_OPACKETS: + return (stats->gptc); + case IFCOUNTER_IBYTES: + return (stats->gorc); + case IFCOUNTER_OBYTES: + return (stats->gotc); + case IFCOUNTER_IMCASTS: + return (stats->mprc); + case IFCOUNTER_OMCASTS: + return (stats->mptc); case IFCOUNTER_IERRORS: return (adapter->dropped_pkts + stats->rxerrc + stats->crcerrs + stats->algnerrc + - stats->ruc + stats->roc + stats->mpc + stats->cexterr); + stats->ruc + stats->roc + stats->cexterr); case IFCOUNTER_OERRORS: return (stats->ecol + stats->latecol + adapter->watchdog_events); case IFCOUNTER_COLLISIONS: return (stats->colc); + case IFCOUNTER_IQDROPS: + return (stats->mpc); +#ifndef IGB_LEGACY_TX + case IFCOUNTER_OQDROPS: + rv = 0; + txr = adapter->tx_rings; + for (int i = 0; i < adapter->num_queues; i++, txr++) + rv += txr->br->br_drops; + return (rv); +#endif default: return (if_get_counter_default(ifp, cnt)); } Modified: head/sys/dev/ixgbe/if_ix.c ============================================================================== --- head/sys/dev/ixgbe/if_ix.c Thu Apr 30 18:11:43 2015 (r282279) +++ head/sys/dev/ixgbe/if_ix.c Thu Apr 30 18:23:38 2015 (r282280) @@ -3592,6 +3592,8 @@ static uint64_t ixgbe_get_counter(struct ifnet *ifp, ift_counter cnt) { struct adapter *adapter; + struct tx_ring *txr; + uint64_t rv; adapter = if_getsoftc(ifp); @@ -3612,6 +3614,12 @@ ixgbe_get_counter(struct ifnet *ifp, ift return (0); case IFCOUNTER_IQDROPS: return (adapter->iqdrops); + case IFCOUNTER_OQDROPS: + rv = 0; + txr = adapter->tx_rings; + for (int i = 0; i < adapter->num_queues; i++, txr++) + rv += txr->br->br_drops; + return (rv); case IFCOUNTER_IERRORS: return (adapter->ierrors); default: @@ -3790,6 +3798,9 @@ ixgbe_add_hw_stats(struct adapter *adapt SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_packets", CTLFLAG_RD, &txr->total_packets, "Queue Packets Transmitted"); + SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "br_drops", + CTLFLAG_RD, &txr->br->br_drops, + "Packets dropped in buf_ring"); } for (int i = 0; i < adapter->num_queues; i++, rxr++) { Modified: head/sys/dev/ixl/ixl.h ============================================================================== --- head/sys/dev/ixl/ixl.h Thu Apr 30 18:11:43 2015 (r282279) +++ head/sys/dev/ixl/ixl.h Thu Apr 30 18:23:38 2015 (r282280) @@ -324,7 +324,7 @@ #define IXL_SET_IMCASTS(vsi, count) (vsi)->imcasts = (count) #define IXL_SET_OMCASTS(vsi, count) (vsi)->omcasts = (count) #define IXL_SET_IQDROPS(vsi, count) (vsi)->iqdrops = (count) -#define IXL_SET_OQDROPS(vsi, count) (vsi)->iqdrops = (count) +#define IXL_SET_OQDROPS(vsi, count) (vsi)->oqdrops = (count) #define IXL_SET_NOPROTO(vsi, count) (vsi)->noproto = (count) #else #define IXL_SET_IPACKETS(vsi, count) (vsi)->ifp->if_ipackets = (count)