Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jul 2016 15:43:53 GMT
From:      vincenzo@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r305826 - soc2016/vincenzo/head/sys/dev/netmap
Message-ID:  <201607081543.u68Fhrke007628@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vincenzo
Date: Fri Jul  8 15:43:52 2016
New Revision: 305826
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305826

Log:
   freebsd: ptnet_rx_slot: remove argument and cache pointers

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 Jul  8 15:43:44 2016	(r305825)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c	Fri Jul  8 15:43:52 2016	(r305826)
@@ -1533,13 +1533,15 @@
 }
 
 static inline int
-ptnet_rx_slot(uint8_t *nmbuf, unsigned int nmbuf_len, struct mbuf **mtail,
-	      uint8_t **mdata)
+ptnet_rx_slot(uint8_t *nmbuf, unsigned int nmbuf_len, struct mbuf **mtail_p)
 {
+	struct mbuf *mtail = *mtail_p;
+	uint8_t *mdata = mtod(mtail, uint8_t *) + mtail->m_len;
+
 	do {
 		unsigned int copy;
 
-		if ((*mtail)->m_len == MCLBYTES) {
+		if (mtail->m_len == MCLBYTES) {
 			struct mbuf *mf;
 
 			mf = m_getcl(M_NOWAIT, MT_DATA, 0);
@@ -1547,23 +1549,23 @@
 				return ENOMEM;
 			}
 
-			(*mtail)->m_next = mf;
-			(*mtail) = mf;
-			*mdata = mtod(*mtail, uint8_t *);
-			(*mtail)->m_len = 0;
+			mtail->m_next = mf;
+			mtail = *mtail_p = mf;
+			mdata = mtod(mtail, uint8_t *);
+			mtail->m_len = 0;
 		}
 
-		copy = MCLBYTES - (*mtail)->m_len;
+		copy = MCLBYTES - mtail->m_len;
 		if (nmbuf_len < copy) {
 			copy = nmbuf_len;
 		}
 
-		memcpy(*mdata, nmbuf, copy);
+		memcpy(mdata, nmbuf, copy);
 
 		nmbuf += copy;
 		nmbuf_len -= copy;
-		*mdata += copy;
-		(*mtail)->m_len += copy;
+		mdata += copy;
+		mtail->m_len += copy;
 	} while (nmbuf_len);
 
 	return 0;
@@ -1590,7 +1592,6 @@
 		unsigned int prev_head = head;
 		struct mbuf *mhead, *mtail;
 		struct netmap_slot *slot;
-		uint8_t *mdata;
 
 		if (head == ring->tail) {
 			/* We ran out of slot, let's see if the host has
@@ -1636,7 +1637,6 @@
 		M_HASHTYPE_SET(mhead, M_HASHTYPE_OPAQUE);
 
 		/* Initialize state variables. */
-		mdata = mtod(mtail, uint8_t *);
 		mtail->m_len = 0;
 
 		/* Scan all the netmap slots containing the current packet. */
@@ -1651,8 +1651,7 @@
 					  head, ring->tail, slot->len,
 					  slot->flags));
 
-			err = ptnet_rx_slot(NMB(na, slot), slot->len,
-					    &mtail, &mdata);
+			err = ptnet_rx_slot(NMB(na, slot), slot->len, &mtail);
 			if (unlikely(err)) {
 				/* Ouch. We ran out of memory while processing
 				 * a packet. We have to restore the previous



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