Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jun 2014 18:02:32 +0000 (UTC)
From:      Luigi Rizzo <luigi@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267177 - head/sys/dev/netmap
Message-ID:  <201406061802.s56I2WeZ065768@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luigi
Date: Fri Jun  6 18:02:32 2014
New Revision: 267177
URL: http://svnweb.freebsd.org/changeset/base/267177

Log:
  introduce mbq_lock() and mbq_unlock() for the mbq,
  so it is easier to buil the same code on linux
  (this generalizes the change in svn 267142)
  
  MFC after:	3 days

Modified:
  head/sys/dev/netmap/netmap.c
  head/sys/dev/netmap/netmap_mbq.c
  head/sys/dev/netmap/netmap_mbq.h

Modified: head/sys/dev/netmap/netmap.c
==============================================================================
--- head/sys/dev/netmap/netmap.c	Fri Jun  6 17:53:05 2014	(r267176)
+++ head/sys/dev/netmap/netmap.c	Fri Jun  6 18:02:32 2014	(r267177)
@@ -1050,7 +1050,7 @@ netmap_rxsync_from_host(struct netmap_ad
 	(void)pwait;	/* disable unused warnings */
 	(void)td;
 
-	mtx_lock_spin(&q->lock);
+	mbq_lock(q);
 
 	/* First part: import newly received packets */
 	n = mbq_len(q);
@@ -1092,7 +1092,7 @@ netmap_rxsync_from_host(struct netmap_ad
 	if (kring->rcur == kring->rtail && td) /* no bufs available */
 		selrecord(td, &kring->si);
 
-	mtx_unlock_spin(&q->lock);
+	mbq_unlock(q);
 	return ret;
 }
 
@@ -2459,7 +2459,7 @@ netmap_transmit(struct ifnet *ifp, struc
 	 * not possible on Linux).
 	 * Also avoid overflowing the queue.
 	 */
-	mtx_lock_spin(&q->lock);
+	mbq_lock(q);
 
         space = kring->nr_hwtail - kring->nr_hwcur;
         if (space < 0)
@@ -2476,7 +2476,7 @@ netmap_transmit(struct ifnet *ifp, struc
 		m = NULL;
 		error = 0;
 	}
-	mtx_unlock_spin(&q->lock);
+	mbq_unlock(q);
 
 done:
 	if (m)

Modified: head/sys/dev/netmap/netmap_mbq.c
==============================================================================
--- head/sys/dev/netmap/netmap_mbq.c	Fri Jun  6 17:53:05 2014	(r267176)
+++ head/sys/dev/netmap/netmap_mbq.c	Fri Jun  6 18:02:32 2014	(r267177)
@@ -76,9 +76,9 @@ static inline void __mbq_enqueue(struct 
 
 void mbq_safe_enqueue(struct mbq *q, struct mbuf *m)
 {
-    mtx_lock_spin(&q->lock);
+    mbq_lock(q);
     __mbq_enqueue(q, m);
-    mtx_unlock_spin(&q->lock);
+    mbq_unlock(q);
 }
 
 
@@ -110,9 +110,9 @@ struct mbuf *mbq_safe_dequeue(struct mbq
 {
     struct mbuf *ret;
 
-    mtx_lock_spin(&q->lock);
+    mbq_lock(q);
     ret =  __mbq_dequeue(q);
-    mtx_unlock_spin(&q->lock);
+    mbq_unlock(q);
 
     return ret;
 }

Modified: head/sys/dev/netmap/netmap_mbq.h
==============================================================================
--- head/sys/dev/netmap/netmap_mbq.h	Fri Jun  6 17:53:05 2014	(r267176)
+++ head/sys/dev/netmap/netmap_mbq.h	Fri Jun  6 18:02:32 2014	(r267177)
@@ -62,7 +62,17 @@ void mbq_enqueue(struct mbq *q, struct m
 struct mbuf *mbq_dequeue(struct mbq *q);
 void mbq_purge(struct mbq *q);
 
-/* XXX missing mbq_lock() and mbq_unlock */
+static inline void
+mbq_lock(struct mbq *q)
+{
+	mtx_lock_spin(&q->lock);
+}
+
+static inline void
+mbq_unlock(struct mbq *q)
+{
+	mtx_unlock_spin(&q->lock);
+}
 
 void mbq_safe_init(struct mbq *q);
 void mbq_safe_destroy(struct mbq *q);



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