Date: Mon, 27 Jun 2016 09:33:05 GMT From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r305573 - soc2016/vincenzo/head/sys/dev/netmap Message-ID: <201606270933.u5R9X5Pg025499@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606270933.u5R9X5Pg025499>