From owner-svn-soc-all@freebsd.org Mon Jun 27 09:33:06 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 6221EB84ECA for ; Mon, 27 Jun 2016 09:33:06 +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 3D8962072 for ; Mon, 27 Jun 2016 09:33:06 +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 u5R9X6IP025515 for ; Mon, 27 Jun 2016 09:33:06 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u5R9X5Pg025499 for svn-soc-all@FreeBSD.org; Mon, 27 Jun 2016 09:33:05 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 27 Jun 2016 09:33:05 GMT Message-Id: <201606270933.u5R9X5Pg025499@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: r305573 - 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:06 -0000 Author: vincenzo Date: Mon Jun 27 09:33:05 2016 New Revision: 305573 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305573 Log: freebsd: ptnet_transmit: start using drbr 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 06:41:11 2016 (r305572) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jun 27 09:33:05 2016 (r305573) @@ -802,13 +802,34 @@ DBG(device_printf(sc->dev, "transmit %p\n", m)); pq = sc->queues + 0; + + if (m) { + int err; + + /* Here we are called by the network stack, and not by + * by the taskqueue thread. */ + err = drbr_enqueue(ifp, pq->bufring, m); + m = NULL; /* just to stay safe */ + if (unlikely(err)) { + device_printf(sc->dev, "%s: drbr_enqueue() failed %d\n", + __func__, err); + return err; + } + } + + if (!PTNET_Q_TRYLOCK(pq)) { + /* We failed to acquire the lock, schedule the taskqueue. */ + RD(1, "Deferring TX work"); + taskqueue_enqueue(pq->taskq, &pq->task); + + return 0; + } + ptring = pq->ptring; kring = na->tx_rings + pq->kring_id; ring = kring->ring; lim = kring->nkr_num_slots - 1; - PTNET_Q_LOCK(pq); - /* Update hwcur and hwtail (completed TX slots) as known by the host, * by reading from CSB. */ ptnet_sync_tail(ptring, kring); @@ -818,14 +839,21 @@ nmbuf = NMB(na, slot); nmbuf_bytes = 0; + m = drbr_peek(ifp, pq->bufring); + if (!m) { + device_printf(sc->dev, "%s: Empty drbr\n", __func__); + goto out; + } + if (head == ring->tail) { device_printf(sc->dev, "%s: Drop, no free slots\n", __func__); - m_freem(m); + drbr_putback(ifp, pq->bufring, m); ptring->guest_need_kick = 1; - - return 0; + goto out; } + drbr_advance(ifp, pq->bufring); + for (mf = m; mf; mf = mf->m_next) { uint8_t *mdata = mf->m_data; int mlen = mf->m_len; @@ -879,7 +907,7 @@ if (0) { ptring->guest_need_kick = 1; } - +out: PTNET_Q_UNLOCK(pq); return 0;