From owner-svn-soc-all@freebsd.org Mon Jun 27 09:33:55 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 6C690B84F0E for ; Mon, 27 Jun 2016 09:33:55 +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 60151215C for ; Mon, 27 Jun 2016 09:33:55 +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 u5R9Xtim027112 for ; Mon, 27 Jun 2016 09:33:55 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u5R9XsJo027106 for svn-soc-all@FreeBSD.org; Mon, 27 Jun 2016 09:33:54 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 27 Jun 2016 09:33:54 GMT Message-Id: <201606270933.u5R9XsJo027106@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: r305575 - 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, 27 Jun 2016 09:33:55 -0000 Author: vincenzo Date: Mon Jun 27 09:33:54 2016 New Revision: 305575 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305575 Log: freebsd: ptnet_transmit: limit TX batching 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 Jun 27 09:33:17 2016 (r305574) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jun 27 09:33:54 2016 (r305575) @@ -218,6 +218,9 @@ extern int netmap_initialized; #define PTNET_BUF_RING_SIZE 4096 +#define PTNET_RX_BUDGET 512 +#define PTNET_TX_BATCH 64 + static int ptnet_attach(device_t dev) @@ -783,11 +786,36 @@ ring->tail = kring->rtail = kring->nr_hwtail; } +static void +ptnet_ring_update(struct ptnet_queue *pq, struct netmap_kring *kring, + unsigned int head) +{ + struct netmap_ring *ring = kring->ring; + struct ptnet_ring *ptring = pq->ptring; + + /* Some packets have been pushed to the netmap ring. We have + * to tell the host to process the new packets, updating cur + * and head in the CSB. */ + ring->head = ring->cur = head; + + /* nm_txsync_prologue */ + kring->rcur = kring->rhead = ring->head; + + ptnetmap_guest_write_kring_csb(ptring, kring->rcur, kring->rhead); + + /* Kick the host if needed. */ + if (NM_ACCESS_ONCE(ptring->host_need_kick)) { + ptring->sync_flags = NAF_FORCE_RECLAIM; + bus_write_4(pq->sc->iomem, pq->kick, 0); + } +} + static int ptnet_transmit(struct ifnet *ifp, struct mbuf *m) { struct ptnet_softc *sc = ifp->if_softc; struct netmap_adapter *na = &sc->ptna_dr.hwup.up; + unsigned int batch_count = 0; struct ptnet_ring *ptring; struct netmap_kring *kring; struct netmap_ring *ring; @@ -896,25 +924,16 @@ /* Consume the packet just processed. */ drbr_advance(ifp, pq->bufring); m_freem(m); - } -escape: - if (head != ring->head) { - /* Some packets have been pushed to the netmap ring. We have - * to tell the host to process the new packets, updating cur - * and head in the CSB. */ - ring->head = ring->cur = head; - - /* nm_txsync_prologue */ - kring->rcur = kring->rhead = ring->head; - ptnetmap_guest_write_kring_csb(ptring, kring->rcur, kring->rhead); - - /* Kick the host if needed. */ - if (NM_ACCESS_ONCE(ptring->host_need_kick)) { - ptring->sync_flags = NAF_FORCE_RECLAIM; - bus_write_4(sc->iomem, pq->kick, 0); + if (++batch_count == PTNET_TX_BATCH) { + batch_count = 0; + ptnet_ring_update(pq, kring, head); } } +escape: + if (batch_count) { + ptnet_ring_update(pq, kring, head); + } if (head == ring->tail) { /* Reactivate the interrupts so that we can be notified @@ -1254,8 +1273,6 @@ ptnet_rx_eof(pq); } -#define RX_BUDGET 512 - static int ptnet_rx_eof(struct ptnet_queue *pq) { @@ -1265,7 +1282,7 @@ struct netmap_kring *kring = na->rx_rings + pq->kring_id; struct netmap_ring *ring = kring->ring; unsigned int const lim = kring->nkr_num_slots - 1; - unsigned int budget = RX_BUDGET; + unsigned int budget = PTNET_RX_BUDGET; unsigned int head = ring->head; struct ifnet *ifp = sc->ifp; unsigned int more; @@ -1323,7 +1340,7 @@ * before issuing the last interrupt. */ ptring->guest_need_kick = 1; - if (budget != RX_BUDGET) { + if (budget != PTNET_RX_BUDGET) { /* Some packets have been pushed to the network stack. * We need to update the CSB to tell the host about the new * ring->cur and ring->head (RX buffer refill). */