From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:49 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 683FEB9C835 for ; Mon, 18 Jul 2016 09:09:49 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (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 41D471EEB for ; Mon, 18 Jul 2016 09:09:49 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I99nHK072604 for ; Mon, 18 Jul 2016 09:09:49 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I99mRh072099 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:48 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:48 GMT Message-Id: <201607180909.u6I99mRh072099@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306423 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:49 -0000 Author: vincenzo Date: Mon Jul 18 09:09:48 2016 New Revision: 306423 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306423 Log: freebsd: ptnet: add periodic timer to accumulate statistics Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:39 2016 (r306422) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:48 2016 (r306423) @@ -153,6 +153,8 @@ struct netmap_pt_guest_adapter ptna_dr; /* XXX we should move ptna_dr and backend_regifs inside struct * netmap_pt_guest_adapter and have just one instance of that. */ + + struct callout tick; }; #define PTNET_CORE_LOCK(_sc) mtx_lock(&(_sc)->lock) @@ -178,6 +180,7 @@ static int ptnet_media_change(struct ifnet *ifp); static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr); +static void ptnet_tick(void *opaque); static int ptnet_irqs_init(struct ptnet_softc *sc); static void ptnet_irqs_fini(struct ptnet_softc *sc); @@ -421,6 +424,7 @@ snprintf(sc->lock_name, sizeof(sc->lock_name), "%s", device_get_nameunit(dev)); mtx_init(&sc->lock, sc->lock_name, "ptnet core lock", MTX_DEF); + callout_init_mtx(&sc->tick, &sc->lock, 0); sc->backend_regifs = 0; @@ -483,6 +487,8 @@ ether_poll_deregister(sc->ifp); } #endif + callout_drain(&sc->tick); + if (sc->queues) { /* Drain taskqueues before calling if_detach. */ for (i = 0; i < sc->num_rings; i++) { @@ -887,6 +893,8 @@ device_printf(sc->dev, "%s: min_tx_space = %u\n", __func__, sc->min_tx_space); + callout_reset(&sc->tick, hz, ptnet_tick, sc); + ifp->if_drv_flags |= IFF_DRV_RUNNING; return 0; @@ -921,6 +929,7 @@ * so that after this loop we are sure nobody is working anymore with * the device. This scheme is taken from the vtnet driver. */ ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + callout_stop(&sc->tick); for (i = 0; i < sc->num_rings; i++) { PTNET_Q_LOCK(sc->queues + i); PTNET_Q_UNLOCK(sc->queues + i); @@ -973,6 +982,16 @@ return 0; } +/* Called under core lock. */ +static void +ptnet_tick(void *opaque) +{ + struct ptnet_softc *sc = opaque; + struct ifnet *ifp = sc->ifp; + + (void)ifp; + callout_schedule(&sc->tick, hz); +} static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)