From owner-svn-soc-all@freebsd.org Mon Jul 4 07:43:13 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 F2DF7B91C90 for ; Mon, 4 Jul 2016 07:43:13 +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 D793B25C4 for ; Mon, 4 Jul 2016 07:43:13 +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 u647hDD8049845 for ; Mon, 4 Jul 2016 07:43:13 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u647hDcY049827 for svn-soc-all@FreeBSD.org; Mon, 4 Jul 2016 07:43:13 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 4 Jul 2016 07:43:13 GMT Message-Id: <201607040743.u647hDcY049827@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: r305708 - 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, 04 Jul 2016 07:43:14 -0000 Author: vincenzo Date: Mon Jul 4 07:43:12 2016 New Revision: 305708 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305708 Log: freebsd: run-time computation of min_tx_space 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 4 07:42:39 2016 (r305707) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 4 07:43:12 2016 (r305708) @@ -136,6 +136,8 @@ struct ptnet_queue *rxqueues; struct ptnet_csb *csb; + unsigned int min_tx_space; + struct netmap_pt_guest_adapter *ptna_nm; struct netmap_pt_guest_adapter ptna_dr; /* XXX we should move ptna_dr and backend_regifs inside struct @@ -321,6 +323,8 @@ } } + sc->min_tx_space = 64; /* Safe initial value. */ + err = ptnet_irqs_init(sc); if (err) { goto err_path; @@ -698,6 +702,7 @@ { struct ifnet *ifp = sc->ifp; struct netmap_adapter *na_dr = &sc->ptna_dr.hwup.up; + unsigned int nm_buf_size; int ret; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { @@ -742,6 +747,13 @@ goto err_register; } + nm_buf_size = NETMAP_BUF_SIZE(na_dr); + + KASSERT(nm_buf_size > 0, "Invalid netmap buffer size"); + sc->min_tx_space = 65536 / nm_buf_size + 2; + device_printf(sc->dev, "%s: min_tx_space = %u\n", __func__, + sc->min_tx_space); + ifp->if_drv_flags |= IFF_DRV_RUNNING; return 0; @@ -1164,12 +1176,9 @@ } } -/* This should be computed as MAX_FRAME_SIZE / NETMAP_BUF_SIZE */ -#define PTNET_TX_MIN_SLOTS 33 - -#define PTNET_TX_NOSPACE(h, k) \ - ((((h) < (k)->rtail) ? 0 : (k)->nkr_num_slots) + \ - (k)->rtail - (h)) < PTNET_TX_MIN_SLOTS +#define PTNET_TX_NOSPACE(_h, _k, _min) \ + ((((_h) < (_k)->rtail) ? 0 : (_k)->nkr_num_slots) + \ + (_k)->rtail - (_h)) < (_min) static int ptnet_transmit(struct ifnet *ifp, struct mbuf *m) @@ -1183,6 +1192,7 @@ struct netmap_slot *slot; struct ptnet_queue *pq; unsigned int prev_head; + unsigned int minspace; unsigned int head; unsigned int lim; struct mbuf *mf; @@ -1226,15 +1236,16 @@ ring = kring->ring; lim = kring->nkr_num_slots - 1; head = ring->head; + minspace = sc->min_tx_space; for (;;) { - if (PTNET_TX_NOSPACE(head, kring)) { + if (PTNET_TX_NOSPACE(head, kring, minspace)) { /* We ran out of slot, let's see if the host has * freed up some, by reading hwcur and hwtail from * the CSB. */ ptnet_sync_tail(ptring, kring); - if (PTNET_TX_NOSPACE(head, kring)) { + if (PTNET_TX_NOSPACE(head, kring, minspace)) { /* Still no slots available. Reactivate the * interrupts so that we can be notified * when some free slots are made available by @@ -1243,7 +1254,8 @@ /* Double-check. */ ptnet_sync_tail(ptring, kring); - if (likely(PTNET_TX_NOSPACE(head, kring))) { + if (likely(PTNET_TX_NOSPACE(head, kring, + minspace))) { break; }