From owner-svn-src-all@FreeBSD.ORG Wed Sep 24 12:19:01 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8CF72F96; Wed, 24 Sep 2014 12:19:01 +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 6CF82139; Wed, 24 Sep 2014 12:19:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8OCJ1Ch049263; Wed, 24 Sep 2014 12:19:01 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8OCJ1x4049262; Wed, 24 Sep 2014 12:19:01 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201409241219.s8OCJ1x4049262@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 24 Sep 2014 12:19:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272068 - head/sys/dev/wi 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: Wed, 24 Sep 2014 12:19:01 -0000 Author: glebius Date: Wed Sep 24 12:19:00 2014 New Revision: 272068 URL: http://svnweb.freebsd.org/changeset/base/272068 Log: - Provide wi_get_counter() to return counters that are not collected, but taken from hardware. - Mechanically convert to if_inc_counter() the rest of counters. Modified: head/sys/dev/wi/if_wi.c Modified: head/sys/dev/wi/if_wi.c ============================================================================== --- head/sys/dev/wi/if_wi.c Wed Sep 24 11:58:23 2014 (r272067) +++ head/sys/dev/wi/if_wi.c Wed Sep 24 12:19:00 2014 (r272068) @@ -132,6 +132,7 @@ static int wi_reset(struct wi_softc *); static void wi_watchdog(void *); static int wi_ioctl(struct ifnet *, u_long, caddr_t); static void wi_media_status(struct ifnet *, struct ifmediareq *); +static uint64_t wi_get_counter(struct ifnet *, ift_counter); static void wi_rx_intr(struct wi_softc *); static void wi_tx_intr(struct wi_softc *); @@ -337,6 +338,7 @@ wi_attach(device_t dev) ifp->if_ioctl = wi_ioctl; ifp->if_start = wi_start; ifp->if_init = wi_init; + ifp->if_get_counter = wi_get_counter; IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; IFQ_SET_READY(&ifp->if_snd); @@ -1028,7 +1030,7 @@ wi_start_locked(struct ifnet *ifp) continue; sc->sc_txnext = cur = (cur + 1) % sc->sc_ntxbuf; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } } @@ -1055,7 +1057,7 @@ wi_start_tx(struct ifnet *ifp, struct wi || wi_mwrite_bap(sc, fid, off, m0, m0->m_pkthdr.len) != 0; m_freem(m0); if (error) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return -1; } sc->sc_txd[cur].d_len = off; @@ -1182,7 +1184,7 @@ wi_watchdog(void *arg) if (sc->sc_tx_timer && --sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); wi_init_locked(ifp->if_softc); return; } @@ -1327,7 +1329,7 @@ wi_rx_intr(struct wi_softc *sc) /* First read in the frame header */ if (wi_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr))) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: read fid %x failed\n", fid)); return; } @@ -1338,7 +1340,7 @@ wi_rx_intr(struct wi_softc *sc) status = le16toh(frmhdr.wi_status); if (status & WI_STAT_ERRSTAT) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: fid %x error status %x\n", fid, status)); return; } @@ -1353,7 +1355,7 @@ wi_rx_intr(struct wi_softc *sc) if (off + len > MCLBYTES) { if (ic->ic_opmode != IEEE80211_M_MONITOR) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: oversized packet\n")); return; } else @@ -1366,7 +1368,7 @@ wi_rx_intr(struct wi_softc *sc) m = m_gethdr(M_NOWAIT, MT_DATA); if (m == NULL) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: MGET failed\n")); return; } @@ -1450,11 +1452,9 @@ wi_tx_ex_intr(struct wi_softc *sc) printf(", status=0x%x", status); printf("\n"); } - ifp->if_oerrors++; - } else { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + } else DPRINTF(("port disconnected\n")); - ifp->if_collisions++; /* XXX */ - } } else DPRINTF(("wi_tx_ex_intr: read fid %x failed\n", fid)); CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX_EXC); @@ -1497,8 +1497,7 @@ wi_tx_intr(struct wi_softc *sc) static __noinline void wi_info_intr(struct wi_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = sc->sc_ifp->if_l2com; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); int i, fid, len, off; u_int16_t ltbuf[2]; @@ -1562,9 +1561,6 @@ wi_info_intr(struct wi_softc *sc) #endif *ptr += stat; } - ifp->if_collisions = sc->sc_stats.wi_tx_single_retries + - sc->sc_stats.wi_tx_multi_retries + - sc->sc_stats.wi_tx_retry_limit; break; default: DPRINTF(("wi_info_intr: got fid %x type %x len %d\n", fid, @@ -1575,6 +1571,23 @@ finish: CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO); } +static uint64_t +wi_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct wi_softc *sc; + + sc = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_COLLISIONS: + return (sc->sc_stats.wi_tx_single_retries + + sc->sc_stats.wi_tx_multi_retries + + sc->sc_stats.wi_tx_retry_limit); + default: + return (if_get_counter_default(ifp, cnt)); + } +} + static int wi_write_multi(struct wi_softc *sc) {