Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2016 16:23:46 GMT
From:      vincenzo@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r305294 - soc2016/vincenzo/head/sys/dev/netmap
Message-ID:  <201606171623.u5HGNkbP024042@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vincenzo
Date: Fri Jun 17 16:23:46 2016
New Revision: 305294
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305294

Log:
   freebsd: ptnet_rx_eof: add mbuf allocation

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:23:37 2016	(r305293)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c	Fri Jun 17 16:23:46 2016	(r305294)
@@ -1167,8 +1167,18 @@
 		struct netmap_slot *slot = ring->slot + head;
 		unsigned int nmbuf_len = slot->len;
 		uint8_t *nmbuf = NMB(na, slot);
-		struct mbuf *m = NULL;
+		struct mbuf *m;
 
+		if (unlikely(nmbuf_len > MCLBYTES)) {
+			RD(1, "Dropping long frame: len %u > %u",
+			      nmbuf_len, MCLBYTES);
+			goto next;
+		}
+
+		/* We use m_getcl() to allocate an mbuf with standard
+		 * cluster size (MCLBYTES). In the future we could use m_getjcl()
+		 * to choose different sizes. */
+		m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
 		if (unlikely(m == NULL)) {
 			device_printf(sc->dev, "%s: failed to allocate mbuf"
 				      "(len=%d)\n", __func__, nmbuf_len);
@@ -1187,7 +1197,7 @@
 		PTNET_Q_UNLOCK(pq);
 		(*ifp->if_input)(ifp, m);
 		PTNET_Q_LOCK(pq);
-
+next:
 		head = nm_next(head, lim);
 		budget--;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606171623.u5HGNkbP024042>