From owner-svn-soc-all@freebsd.org Fri Jun 17 16:22:48 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 08D35A77622 for ; Fri, 17 Jun 2016 16:22:48 +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 D6A4924E2 for ; Fri, 17 Jun 2016 16:22:47 +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 u5HGMlrP022923 for ; Fri, 17 Jun 2016 16:22:47 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u5HGMl1U022888 for svn-soc-all@FreeBSD.org; Fri, 17 Jun 2016 16:22:47 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 17 Jun 2016 16:22:47 GMT Message-Id: <201606171622.u5HGMl1U022888@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: r305291 - 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: Fri, 17 Jun 2016 16:22:48 -0000 Author: vincenzo Date: Fri Jun 17 16:22:46 2016 New Revision: 305291 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305291 Log: freebsd: ptnet: sketch ptnet_rx_eof function 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 Fri Jun 17 16:22:28 2016 (r305290) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Jun 17 16:22:46 2016 (r305291) @@ -174,6 +174,8 @@ static void ptnet_tx_intr(void *opaque); static void ptnet_rx_intr(void *opaque); +static int ptnet_rx_eof(struct ptnet_queue *pq); + static device_method_t ptnet_methods[] = { DEVMETHOD(device_probe, ptnet_probe), DEVMETHOD(device_attach, ptnet_attach), @@ -802,8 +804,7 @@ /* Tell the host to process the new packets, updating cur and * head in the CSB. */ - ptnetmap_guest_write_kring_csb(ptring, kring->rcur, - kring->rhead); + ptnetmap_guest_write_kring_csb(ptring, kring->rcur, kring->rhead); /* Ask for a kick from a guest to the host if needed. */ if (NM_ACCESS_ONCE(ptring->host_need_kick)) { @@ -1137,4 +1138,53 @@ if (netmap_rx_irq(sc->ifp, pq->kring_id, &unused) != NM_IRQ_PASS) { return; } + + ptnet_rx_eof(pq); +} + +static int +ptnet_rx_eof(struct ptnet_queue *pq) +{ + struct ptnet_softc *sc = pq->sc; + struct ptnet_ring *ptring = pq->ptring; + struct netmap_adapter *na = &sc->ptna_dr.hwup.up; + 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 head = ring->head; + struct ifnet *ifp = sc->ifp; + + PTNET_Q_LOCK(pq); + + /* Update hwtail, rtail, tail and hwcur to what is known from the host, + * reading from CSB. */ + ptnet_sync_tail(ptring, kring); + + kring->nr_kflags &= ~NKR_PENDINTR; + + while (head != ring->tail) { + struct netmap_slot *slot = ring->slot + head; + unsigned int nmbuf_len = slot->len; + uint8_t *nmbuf = NMB(na, slot); + struct mbuf *m = NULL; + + if (unlikely(m == NULL)) { + device_printf(sc->dev, "%s: failed to allocate mbuf" + "(len=%d)\n", __func__, nmbuf_len); + break; + } + + memcpy(m->m_data, nmbuf, nmbuf_len); + m->m_len = nmbuf_len; + + head = nm_next(head, lim); + + PTNET_Q_UNLOCK(pq); + (*ifp->if_input)(ifp, m); + PTNET_Q_LOCK(pq); + } + + PTNET_Q_UNLOCK(pq); + + return 0; }