From owner-svn-src-head@FreeBSD.ORG Fri Jun 6 18:02:33 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 666EE162; Fri, 6 Jun 2014 18:02:33 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 471AC2E02; Fri, 6 Jun 2014 18:02:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s56I2Xn4065772; Fri, 6 Jun 2014 18:02:33 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s56I2WeZ065768; Fri, 6 Jun 2014 18:02:32 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201406061802.s56I2WeZ065768@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 6 Jun 2014 18:02:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267177 - head/sys/dev/netmap X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jun 2014 18:02:33 -0000 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);