svn commit: r278221 - in head/sys/dev/sfxge: . common

Andrew Rybchenko arybchik at FreeBSD.org
Wed Feb 4 20:04:00 UTC 2015


Author: arybchik
Date: Wed Feb  4 20:03:57 2015
New Revision: 278221
URL: https://svnweb.freebsd.org/changeset/base/278221

Log:
  sfxge: Add macros to init, destroy, acquire, release and assert locks
  
  Sponsored by:   Solarflare Communications, Inc.
  Approved by:    gnn (mentor)

Modified:
  head/sys/dev/sfxge/common/efsys.h
  head/sys/dev/sfxge/sfxge.c
  head/sys/dev/sfxge/sfxge.h
  head/sys/dev/sfxge/sfxge_ev.c
  head/sys/dev/sfxge/sfxge_mcdi.c
  head/sys/dev/sfxge/sfxge_port.c
  head/sys/dev/sfxge/sfxge_rx.c
  head/sys/dev/sfxge/sfxge_tx.c
  head/sys/dev/sfxge/sfxge_tx.h

Modified: head/sys/dev/sfxge/common/efsys.h
==============================================================================
--- head/sys/dev/sfxge/common/efsys.h	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/common/efsys.h	Wed Feb  4 20:03:57 2015	(r278221)
@@ -517,6 +517,15 @@ typedef struct efsys_bar_s {
 	struct resource		*esb_res;
 } efsys_bar_t;
 
+#define	SFXGE_BAR_LOCK_INIT(_esbp, _name)				\
+	mtx_init(&(_esbp)->esb_lock, (_name), NULL, MTX_DEF)
+#define	SFXGE_BAR_LOCK_DESTROY(_esbp)					\
+	mtx_destroy(&(_esbp)->esb_lock)
+#define	SFXGE_BAR_LOCK(_esbp)						\
+	mtx_lock(&(_esbp)->esb_lock)
+#define	SFXGE_BAR_UNLOCK(_esbp)						\
+	mtx_unlock(&(_esbp)->esb_lock)
+
 #define	EFSYS_BAR_READD(_esbp, _offset, _edp, _lock)			\
 	do {								\
 		_NOTE(CONSTANTCONDITION)				\
@@ -525,7 +534,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_lock(&((_esbp)->esb_lock));			\
+			SFXGE_BAR_LOCK(_esbp);				\
 									\
 		(_edp)->ed_u32[0] = bus_space_read_4((_esbp)->esb_tag,	\
 		    (_esbp)->esb_handle, (_offset));			\
@@ -535,7 +544,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_unlock(&((_esbp)->esb_lock));		\
+			SFXGE_BAR_UNLOCK(_esbp);			\
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 
@@ -545,7 +554,7 @@ typedef struct efsys_bar_s {
 		KASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)),	\
 		    ("not power of 2 aligned"));			\
 									\
-		mtx_lock(&((_esbp)->esb_lock));				\
+		SFXGE_BAR_LOCK(_esbp);					\
 									\
 		(_eqp)->eq_u32[0] = bus_space_read_4((_esbp)->esb_tag,	\
 		    (_esbp)->esb_handle, (_offset));			\
@@ -556,7 +565,7 @@ typedef struct efsys_bar_s {
 		    uint32_t, (_eqp)->eq_u32[1],			\
 		    uint32_t, (_eqp)->eq_u32[0]);			\
 									\
-		mtx_unlock(&((_esbp)->esb_lock));			\
+		SFXGE_BAR_UNLOCK(_esbp);				\
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 
@@ -568,7 +577,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_lock(&((_esbp)->esb_lock));			\
+			SFXGE_BAR_LOCK(_esbp);				\
 									\
 		(_eop)->eo_u32[0] = bus_space_read_4((_esbp)->esb_tag,	\
 		    (_esbp)->esb_handle, (_offset));			\
@@ -587,7 +596,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_unlock(&((_esbp)->esb_lock));		\
+			SFXGE_BAR_UNLOCK(_esbp);			\
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 
@@ -599,7 +608,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_lock(&((_esbp)->esb_lock));			\
+			SFXGE_BAR_LOCK(_esbp);			\
 									\
 		EFSYS_PROBE2(bar_writed, unsigned int, (_offset),	\
 		    uint32_t, (_edp)->ed_u32[0]);			\
@@ -609,7 +618,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_unlock(&((_esbp)->esb_lock));		\
+			SFXGE_BAR_UNLOCK(_esbp);		\
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 
@@ -619,7 +628,7 @@ typedef struct efsys_bar_s {
 		KASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)),	\
 		    ("not power of 2 aligned"));			\
 									\
-		mtx_lock(&((_esbp)->esb_lock));				\
+		SFXGE_BAR_LOCK(_esbp);					\
 									\
 		EFSYS_PROBE3(bar_writeq, unsigned int, (_offset),	\
 		    uint32_t, (_eqp)->eq_u32[1],			\
@@ -630,7 +639,7 @@ typedef struct efsys_bar_s {
 		bus_space_write_4((_esbp)->esb_tag, (_esbp)->esb_handle,\
 		    (_offset+4), (_eqp)->eq_u32[1]);			\
 									\
-		mtx_unlock(&((_esbp)->esb_lock));			\
+		SFXGE_BAR_UNLOCK(_esbp);				\
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 
@@ -642,7 +651,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_lock(&((_esbp)->esb_lock));			\
+			SFXGE_BAR_LOCK(_esbp);				\
 									\
 		EFSYS_PROBE5(bar_writeo, unsigned int, (_offset),	\
 		    uint32_t, (_eop)->eo_u32[3],			\
@@ -661,7 +670,7 @@ typedef struct efsys_bar_s {
 									\
 		_NOTE(CONSTANTCONDITION)				\
 		if (_lock)						\
-			mtx_unlock(&((_esbp)->esb_lock));		\
+			SFXGE_BAR_UNLOCK(_esbp);			\
 	_NOTE(CONSTANTCONDITION)					\
 	} while (B_FALSE)
 

Modified: head/sys/dev/sfxge/sfxge.c
==============================================================================
--- head/sys/dev/sfxge/sfxge.c	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge.c	Wed Feb  4 20:03:57 2015	(r278221)
@@ -95,7 +95,7 @@ sfxge_start(struct sfxge_softc *sc)
 {
 	int rc;
 
-	sx_assert(&sc->softc_lock, LA_XLOCKED);
+	SFXGE_ADAPTER_LOCK_ASSERT_OWNED(sc);
 
 	if (sc->init_state == SFXGE_STARTED)
 		return (0);
@@ -164,15 +164,15 @@ sfxge_if_init(void *arg)
 
 	sc = (struct sfxge_softc *)arg;
 
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 	(void)sfxge_start(sc);
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 }
 
 static void
 sfxge_stop(struct sfxge_softc *sc)
 {
-	sx_assert(&sc->softc_lock, LA_XLOCKED);
+	SFXGE_ADAPTER_LOCK_ASSERT_OWNED(sc);
 
 	if (sc->init_state != SFXGE_STARTED)
 		return;
@@ -212,7 +212,7 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
 
 	switch (command) {
 	case SIOCSIFFLAGS:
-		sx_xlock(&sc->softc_lock);
+		SFXGE_ADAPTER_LOCK(sc);
 		if (ifp->if_flags & IFF_UP) {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 				if ((ifp->if_flags ^ sc->if_flags) &
@@ -225,7 +225,7 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 				sfxge_stop(sc);
 		sc->if_flags = ifp->if_flags;
-		sx_xunlock(&sc->softc_lock);
+		SFXGE_ADAPTER_UNLOCK(sc);
 		break;
 	case SIOCSIFMTU:
 		if (ifr->ifr_mtu == ifp->if_mtu) {
@@ -238,11 +238,11 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
 			error = 0;
 		} else {
 			/* Restart required */
-			sx_xlock(&sc->softc_lock);
+			SFXGE_ADAPTER_LOCK(sc);
 			sfxge_stop(sc);
 			ifp->if_mtu = ifr->ifr_mtu;
 			error = sfxge_start(sc);
-			sx_xunlock(&sc->softc_lock);
+			SFXGE_ADAPTER_UNLOCK(sc);
 			if (error != 0) {
 				ifp->if_flags &= ~IFF_UP;
 				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
@@ -256,7 +256,7 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
 			sfxge_mac_filter_set(sc);
 		break;
 	case SIOCSIFCAP:
-		sx_xlock(&sc->softc_lock);
+		SFXGE_ADAPTER_LOCK(sc);
 
 		/*
 		 * The networking core already rejects attempts to
@@ -266,7 +266,7 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
 		 */
 		if (~ifr->ifr_reqcap & SFXGE_CAP_FIXED) {
 			error = EINVAL;
-			sx_xunlock(&sc->softc_lock);
+			SFXGE_ADAPTER_UNLOCK(sc);
 			break;
 		}
 
@@ -280,7 +280,7 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
 		else
 			ifp->if_hwassist &= ~CSUM_TSO;
 
-		sx_xunlock(&sc->softc_lock);
+		SFXGE_ADAPTER_UNLOCK(sc);
 		break;
 	case SIOCSIFMEDIA:
 	case SIOCGIFMEDIA:
@@ -298,9 +298,9 @@ sfxge_ifnet_fini(struct ifnet *ifp)
 {
 	struct sfxge_softc *sc = ifp->if_softc;
 
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 	sfxge_stop(sc);
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 
 	ifmedia_removeall(&sc->media);
 	ether_ifdetach(ifp);
@@ -376,7 +376,7 @@ sfxge_bar_init(struct sfxge_softc *sc)
 	}
 	esbp->esb_tag = rman_get_bustag(esbp->esb_res);
 	esbp->esb_handle = rman_get_bushandle(esbp->esb_res);
-	mtx_init(&esbp->esb_lock, "sfxge_efsys_bar", NULL, MTX_DEF);
+	SFXGE_BAR_LOCK_INIT(esbp, "sfxge_efsys_bar");
 
 	return (0);
 }
@@ -388,7 +388,7 @@ sfxge_bar_fini(struct sfxge_softc *sc)
 
 	bus_release_resource(sc->dev, SYS_RES_MEMORY, esbp->esb_rid,
 	    esbp->esb_res);
-	mtx_destroy(&esbp->esb_lock);
+	SFXGE_BAR_LOCK_DESTROY(esbp);
 }
 
 static int
@@ -401,7 +401,7 @@ sfxge_create(struct sfxge_softc *sc)
 
 	dev = sc->dev;
 
-	sx_init(&sc->softc_lock, "sfxge_softc");
+	SFXGE_ADAPTER_LOCK_INIT(sc, "sfxge_softc");
 
 	sc->max_rss_channels = 0;
 	snprintf(rss_param_name, sizeof(rss_param_name),
@@ -545,7 +545,7 @@ fail3:
 
 fail:
 	sc->dev = NULL;
-	sx_destroy(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK_DESTROY(sc);
 	return (error);
 }
 
@@ -594,7 +594,7 @@ sfxge_destroy(struct sfxge_softc *sc)
 	taskqueue_drain(taskqueue_thread, &sc->task_reset);
 
 	/* Destroy the softc lock. */
-	sx_destroy(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK_DESTROY(sc);
 }
 
 static int
@@ -696,7 +696,7 @@ sfxge_reset(void *arg, int npending)
 
 	sc = (struct sfxge_softc *)arg;
 
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 
 	if (sc->init_state != SFXGE_STARTED)
 		goto done;
@@ -709,7 +709,7 @@ sfxge_reset(void *arg, int npending)
 			      rc);
 
 done:
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 }
 
 void

Modified: head/sys/dev/sfxge/sfxge.h
==============================================================================
--- head/sys/dev/sfxge/sfxge.h	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge.h	Wed Feb  4 20:03:57 2015	(r278221)
@@ -314,4 +314,48 @@ extern int sfxge_port_ifmedia_init(struc
 
 #define	SFXGE_MAX_MTU (9 * 1024)
 
+#define	SFXGE_ADAPTER_LOCK_INIT(_sc, _name)				\
+	sx_init(&(_sc)->softc_lock, (_name))
+#define	SFXGE_ADAPTER_LOCK_DESTROY(_sc)					\
+	sx_destroy(&(_sc)->softc_lock)
+#define	SFXGE_ADAPTER_LOCK(_sc)						\
+	sx_xlock(&(_sc)->softc_lock)
+#define	SFXGE_ADAPTER_UNLOCK(_sc)					\
+	sx_xunlock(&(_sc)->softc_lock)
+#define	SFXGE_ADAPTER_LOCK_ASSERT_OWNED(_sc)				\
+	sx_assert(&(_sc)->softc_lock, LA_XLOCKED)
+
+#define	SFXGE_PORT_LOCK_INIT(_port, _name)				\
+	mtx_init(&(_port)->lock, (_name), NULL, MTX_DEF)
+#define	SFXGE_PORT_LOCK_DESTROY(_port)					\
+	mtx_destroy(&(_port)->lock)
+#define	SFXGE_PORT_LOCK(_port)						\
+	mtx_lock(&(_port)->lock)
+#define	SFXGE_PORT_UNLOCK(_port)					\
+	mtx_unlock(&(_port)->lock)
+#define	SFXGE_PORT_LOCK_ASSERT_OWNED(_port)				\
+	mtx_assert(&(_port)->lock, MA_OWNED)
+
+#define	SFXGE_MCDI_LOCK_INIT(_mcdi, _name)				\
+	mtx_init(&(_mcdi)->lock, (_name), NULL, MTX_DEF)
+#define	SFXGE_MCDI_LOCK_DESTROY(_mcdi)					\
+	mtx_destroy(&(_mcdi)->lock)
+#define	SFXGE_MCDI_LOCK(_mcdi)						\
+	mtx_lock(&(_mcdi)->lock)
+#define	SFXGE_MCDI_UNLOCK(_mcdi)					\
+	mtx_unlock(&(_mcdi)->lock)
+#define	SFXGE_MCDI_LOCK_ASSERT_OWNED(_mcdi)				\
+	mtx_assert(&(_mcdi)->lock, MA_OWNED)
+
+#define	SFXGE_EVQ_LOCK_INIT(_evq, _name)				\
+	mtx_init(&(_evq)->lock, (_name), NULL, MTX_DEF)
+#define	SFXGE_EVQ_LOCK_DESTROY(_evq)					\
+	mtx_destroy(&(_evq)->lock)
+#define	SFXGE_EVQ_LOCK(_evq)						\
+	mtx_lock(&(_evq)->lock)
+#define	SFXGE_EVQ_UNLOCK(_evq)						\
+	mtx_unlock(&(_evq)->lock)
+#define	SFXGE_EVQ_LOCK_ASSERT_OWNED(_evq)				\
+	mtx_assert(&(_evq)->lock, MA_OWNED)
+
 #endif /* _SFXGE_H */

Modified: head/sys/dev/sfxge/sfxge_ev.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_ev.c	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge_ev.c	Wed Feb  4 20:03:57 2015	(r278221)
@@ -415,7 +415,7 @@ sfxge_ev_stat_update(struct sfxge_softc 
 	unsigned int index;
 	clock_t now;
 
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 
 	if (sc->evq[0]->init_state != SFXGE_EVQ_STARTED)
 		goto out;
@@ -429,12 +429,12 @@ sfxge_ev_stat_update(struct sfxge_softc 
 	/* Add event counts from each event queue in turn */
 	for (index = 0; index < sc->intr.n_alloc; index++) {
 		evq = sc->evq[index];
-		mtx_lock(&evq->lock);
+		SFXGE_EVQ_LOCK(evq);
 		efx_ev_qstats_update(evq->common, sc->ev_stats);
-		mtx_unlock(&evq->lock);
+		SFXGE_EVQ_UNLOCK(evq);
 	}
 out:
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 }
 
 static int
@@ -495,7 +495,7 @@ sfxge_int_mod_handler(SYSCTL_HANDLER_ARG
 	int error;
 	int index;
 
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 
 	if (req->newptr != NULL) {
 		if ((error = SYSCTL_IN(req, &moderation, sizeof(moderation)))
@@ -522,7 +522,7 @@ sfxge_int_mod_handler(SYSCTL_HANDLER_ARG
 	}
 
 out:
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 
 	return (error);
 }
@@ -577,7 +577,7 @@ sfxge_ev_qpoll(struct sfxge_evq *evq)
 {
 	int rc;
 
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 
 	if (evq->init_state != SFXGE_EVQ_STARTING &&
 	    evq->init_state != SFXGE_EVQ_STARTED) {
@@ -607,12 +607,12 @@ sfxge_ev_qpoll(struct sfxge_evq *evq)
 	if ((rc = efx_ev_qprime(evq->common, evq->read_ptr)) != 0)
 		goto fail;
 
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 
 	return (0);
 
 fail:
-	mtx_unlock(&(evq->lock));
+	SFXGE_EVQ_UNLOCK(evq);
 	return (rc);
 }
 
@@ -626,7 +626,7 @@ sfxge_ev_qstop(struct sfxge_softc *sc, u
 	KASSERT(evq->init_state == SFXGE_EVQ_STARTED,
 	    ("evq->init_state != SFXGE_EVQ_STARTED"));
 
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 	evq->init_state = SFXGE_EVQ_INITIALIZED;
 	evq->read_ptr = 0;
 	evq->exception = B_FALSE;
@@ -639,7 +639,7 @@ sfxge_ev_qstop(struct sfxge_softc *sc, u
 	efx_ev_qdestroy(evq->common);
 	efx_sram_buf_tbl_clear(sc->enp, evq->buf_base_id,
 	    EFX_EVQ_NBUFS(evq->entries));
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 }
 
 static int
@@ -669,7 +669,7 @@ sfxge_ev_qstart(struct sfxge_softc *sc, 
 	    evq->buf_base_id, &evq->common)) != 0)
 		goto fail;
 
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 
 	/* Set the default moderation */
 	(void)efx_ev_qmoderate(evq->common, sc->ev_moderation);
@@ -680,7 +680,7 @@ sfxge_ev_qstart(struct sfxge_softc *sc, 
 
 	evq->init_state = SFXGE_EVQ_STARTING;
 
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 
 	/* Wait for the initialization event */
 	count = 0;
@@ -701,10 +701,10 @@ done:
 	return (0);
 
 fail3:
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 	evq->init_state = SFXGE_EVQ_INITIALIZED;
 fail2:
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 	efx_ev_qdestroy(evq->common);
 fail:
 	efx_sram_buf_tbl_clear(sc->enp, evq->buf_base_id,
@@ -785,7 +785,7 @@ sfxge_ev_qfini(struct sfxge_softc *sc, u
 
 	sc->evq[index] = NULL;
 
-	mtx_destroy(&evq->lock);
+	SFXGE_EVQ_LOCK_DESTROY(evq);
 
 	free(evq, M_SFXGE);
 }
@@ -832,7 +832,7 @@ sfxge_ev_qinit(struct sfxge_softc *sc, u
 	sfxge_sram_buf_tbl_alloc(sc, EFX_EVQ_NBUFS(evq->entries),
 				 &evq->buf_base_id);
 
-	mtx_init(&evq->lock, "evq", NULL, MTX_DEF);
+	SFXGE_EVQ_LOCK_INIT(evq, "evq");
 
 	evq->init_state = SFXGE_EVQ_INITIALIZED;
 

Modified: head/sys/dev/sfxge/sfxge_mcdi.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_mcdi.c	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge_mcdi.c	Wed Feb  4 20:03:57 2015	(r278221)
@@ -52,8 +52,7 @@ __FBSDID("$FreeBSD$");
 static void
 sfxge_mcdi_acquire(struct sfxge_mcdi *mcdi)
 {
-
-	mtx_lock(&mcdi->lock);
+	SFXGE_MCDI_LOCK(mcdi);
 	KASSERT(mcdi->state != SFXGE_MCDI_UNINITIALIZED,
 	    ("MCDI not initialized"));
 
@@ -61,15 +60,14 @@ sfxge_mcdi_acquire(struct sfxge_mcdi *mc
 		(void)cv_wait_sig(&mcdi->cv, &mcdi->lock);
 	mcdi->state = SFXGE_MCDI_BUSY;
 
-	mtx_unlock(&mcdi->lock);
+	SFXGE_MCDI_UNLOCK(mcdi);
 }
 
 /* Release ownership of MCDI on request completion. */
 static void
 sfxge_mcdi_release(struct sfxge_mcdi *mcdi)
 {
-
-	mtx_lock(&mcdi->lock);
+	SFXGE_MCDI_LOCK(mcdi);
 	KASSERT((mcdi->state == SFXGE_MCDI_BUSY ||
 	    mcdi->state == SFXGE_MCDI_COMPLETED),
 	    ("MCDI not busy or task not completed"));
@@ -77,7 +75,7 @@ sfxge_mcdi_release(struct sfxge_mcdi *mc
 	mcdi->state = SFXGE_MCDI_INITIALIZED;
 	cv_broadcast(&mcdi->cv);
 
-	mtx_unlock(&mcdi->lock);
+	SFXGE_MCDI_UNLOCK(mcdi);
 }
 
 static void
@@ -160,11 +158,11 @@ sfxge_mcdi_ev_cpl(void *arg)
 	sc = (struct sfxge_softc *)arg;
 	mcdi = &sc->mcdi;
 
-	mtx_lock(&mcdi->lock);
+	SFXGE_MCDI_LOCK(mcdi);
 	KASSERT(mcdi->state == SFXGE_MCDI_BUSY, ("MCDI not busy"));
 	mcdi->state = SFXGE_MCDI_COMPLETED;
 	cv_broadcast(&mcdi->cv);
-	mtx_unlock(&mcdi->lock);
+	SFXGE_MCDI_UNLOCK(mcdi);
 }
 
 static void
@@ -203,7 +201,7 @@ sfxge_mcdi_init(struct sfxge_softc *sc)
 	KASSERT(mcdi->state == SFXGE_MCDI_UNINITIALIZED,
 	    ("MCDI already initialized"));
 
-	mtx_init(&mcdi->lock, "sfxge_mcdi", NULL, MTX_DEF);
+	SFXGE_MCDI_LOCK_INIT(mcdi, "sfxge_mcdi");
 
 	mcdi->state = SFXGE_MCDI_INITIALIZED;
 
@@ -220,7 +218,7 @@ sfxge_mcdi_init(struct sfxge_softc *sc)
 	return (0);
 
 fail:
-	mtx_destroy(&mcdi->lock);
+	SFXGE_MCDI_LOCK_DESTROY(mcdi);
 	mcdi->state = SFXGE_MCDI_UNINITIALIZED;
 	return (rc);
 }
@@ -236,7 +234,7 @@ sfxge_mcdi_fini(struct sfxge_softc *sc)
 	mcdi = &sc->mcdi;
 	emtp = &mcdi->transport;
 
-	mtx_lock(&mcdi->lock);
+	SFXGE_MCDI_LOCK(mcdi);
 	KASSERT(mcdi->state == SFXGE_MCDI_INITIALIZED,
 	    ("MCDI not initialized"));
 
@@ -244,7 +242,7 @@ sfxge_mcdi_fini(struct sfxge_softc *sc)
 	bzero(emtp, sizeof(*emtp));
 
 	cv_destroy(&mcdi->cv);
-	mtx_unlock(&mcdi->lock);
+	SFXGE_MCDI_UNLOCK(mcdi);
 
-	mtx_destroy(&mcdi->lock);
+	SFXGE_MCDI_LOCK_DESTROY(mcdi);
 }

Modified: head/sys/dev/sfxge/sfxge_port.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_port.c	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge_port.c	Wed Feb  4 20:03:57 2015	(r278221)
@@ -48,7 +48,7 @@ sfxge_mac_stat_update(struct sfxge_softc
 	unsigned int count;
 	int rc;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 
 	if (port->init_state != SFXGE_PORT_STARTED) {
 		rc = 0;
@@ -82,7 +82,7 @@ sfxge_mac_stat_update(struct sfxge_softc
 
 	rc = ETIMEDOUT;
 out:
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 	return (rc);
 }
 
@@ -170,7 +170,7 @@ sfxge_port_wanted_fc_handler(SYSCTL_HAND
 	sc = arg1;
 	port = &sc->port;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 
 	if (req->newptr != NULL) {
 		if ((error = SYSCTL_IN(req, &fcntl, sizeof(fcntl))) != 0)
@@ -191,7 +191,7 @@ sfxge_port_wanted_fc_handler(SYSCTL_HAND
 	}
 
 out:
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 
 	return (error);
 }
@@ -207,13 +207,13 @@ sfxge_port_link_fc_handler(SYSCTL_HANDLE
 	sc = arg1;
 	port = &sc->port;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 	if (port->init_state == SFXGE_PORT_STARTED && SFXGE_LINK_UP(sc))
 		efx_mac_fcntl_get(sc->enp, &wanted_fc, &link_fc);
 	else
 		link_fc = 0;
 	error = SYSCTL_OUT(req, &link_fc, sizeof(link_fc));
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 
 	return (error);
 }
@@ -262,7 +262,7 @@ sfxge_mac_poll_work(void *arg, int npend
 	enp = sc->enp;
 	port = &sc->port;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 
 	if (port->init_state != SFXGE_PORT_STARTED)
 		goto done;
@@ -272,7 +272,7 @@ sfxge_mac_poll_work(void *arg, int npend
 	sfxge_mac_link_update(sc, mode);
 
 done:
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 }
 
 static int
@@ -320,7 +320,7 @@ sfxge_mac_filter_set(struct sfxge_softc 
 	struct sfxge_port *port = &sc->port;
 	int rc;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 	/*
 	 * The function may be called without softc_lock held in the
 	 * case of SIOCADDMULTI and SIOCDELMULTI ioctls. ioctl handler
@@ -335,7 +335,7 @@ sfxge_mac_filter_set(struct sfxge_softc 
 		rc = sfxge_mac_filter_set_locked(sc);
 	else
 		rc = 0;
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 	return (rc);
 }
 
@@ -348,7 +348,7 @@ sfxge_port_stop(struct sfxge_softc *sc)
 	port = &sc->port;
 	enp = sc->enp;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 
 	KASSERT(port->init_state == SFXGE_PORT_STARTED,
 	    ("port not started"));
@@ -367,7 +367,7 @@ sfxge_port_stop(struct sfxge_softc *sc)
 	/* Destroy the common code port object. */
 	efx_port_fini(sc->enp);
 
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 }
 
 int
@@ -383,7 +383,7 @@ sfxge_port_start(struct sfxge_softc *sc)
 	port = &sc->port;
 	enp = sc->enp;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 
 	KASSERT(port->init_state == SFXGE_PORT_INITIALIZED,
 	    ("port not initialized"));
@@ -426,7 +426,7 @@ sfxge_port_start(struct sfxge_softc *sc)
 	port->init_state = SFXGE_PORT_STARTED;
 
 	/* Single poll in case there were missing initial events */
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 	sfxge_mac_poll_work(sc, 0);
 
 	return (0);
@@ -439,7 +439,7 @@ fail3:
 fail2:
 	efx_port_fini(sc->enp);
 fail:
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 
 	return (rc);
 }
@@ -453,7 +453,7 @@ sfxge_phy_stat_update(struct sfxge_softc
 	unsigned int count;
 	int rc;
 
-	mtx_lock(&port->lock);
+	SFXGE_PORT_LOCK(port);
 
 	if (port->init_state != SFXGE_PORT_STARTED) {
 		rc = 0;
@@ -487,7 +487,7 @@ sfxge_phy_stat_update(struct sfxge_softc
 
 	rc = ETIMEDOUT;
 out:
-	mtx_unlock(&port->lock);
+	SFXGE_PORT_UNLOCK(port);
 	return (rc);
 }
 
@@ -554,7 +554,7 @@ sfxge_port_fini(struct sfxge_softc *sc)
 	sfxge_dma_free(esmp);
 	free(port->mac_stats.decode_buf, M_SFXGE);
 
-	mtx_destroy(&port->lock);
+	SFXGE_PORT_LOCK_DESTROY(port);
 
 	port->sc = NULL;
 }
@@ -577,7 +577,7 @@ sfxge_port_init(struct sfxge_softc *sc)
 
 	port->sc = sc;
 
-	mtx_init(&port->lock, "sfxge_port", NULL, MTX_DEF);
+	SFXGE_PORT_LOCK_INIT(port, "sfxge_port");
 
 	port->phy_stats.decode_buf = malloc(EFX_PHY_NSTATS * sizeof(uint32_t),
 					    M_SFXGE, M_WAITOK | M_ZERO);
@@ -615,7 +615,7 @@ fail2:
 	sfxge_dma_free(phy_stats_buf);
 fail:
 	free(port->phy_stats.decode_buf, M_SFXGE);
-	(void)mtx_destroy(&port->lock);
+	SFXGE_PORT_LOCK_DESTROY(port);
 	port->sc = NULL;
 	return (rc);
 }
@@ -655,7 +655,7 @@ sfxge_media_status(struct ifnet *ifp, st
 	efx_link_mode_t mode;
 
 	sc = ifp->if_softc;
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 
 	ifmr->ifm_status = IFM_AVALID;
 	ifmr->ifm_active = IFM_ETHER;
@@ -669,7 +669,7 @@ sfxge_media_status(struct ifnet *ifp, st
 		ifmr->ifm_active |= sfxge_port_link_fc_ifm(sc);
 	}
 
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 }
 
 static int
@@ -682,7 +682,7 @@ sfxge_media_change(struct ifnet *ifp)
 	sc = ifp->if_softc;
 	ifm = sc->media.ifm_cur;
 
-	sx_xlock(&sc->softc_lock);
+	SFXGE_ADAPTER_LOCK(sc);
 
 	if (!SFXGE_RUNNING(sc)) {
 		rc = 0;
@@ -695,7 +695,7 @@ sfxge_media_change(struct ifnet *ifp)
 
 	rc = efx_phy_adv_cap_set(sc->enp, ifm->ifm_data);
 out:
-	sx_xunlock(&sc->softc_lock);
+	SFXGE_ADAPTER_UNLOCK(sc);
 
 	return (rc);
 }

Modified: head/sys/dev/sfxge/sfxge_rx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_rx.c	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge_rx.c	Wed Feb  4 20:03:57 2015	(r278221)
@@ -207,7 +207,7 @@ sfxge_rx_qfill(struct sfxge_rxq *rxq, un
 	prefetch_read_many(sc->enp);
 	prefetch_read_many(rxq->common);
 
-	mtx_assert(&evq->lock, MA_OWNED);
+	SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
 
 	if (rxq->init_state != SFXGE_RXQ_STARTED)
 		return;
@@ -749,7 +749,7 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq
 	index = rxq->index;
 	evq = sc->evq[index];
 
-	mtx_assert(&evq->lock, MA_OWNED);
+	SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
 
 	completed = rxq->completed;
 	while (completed != rxq->pending) {
@@ -834,7 +834,7 @@ sfxge_rx_qstop(struct sfxge_softc *sc, u
 	rxq = sc->rxq[index];
 	evq = sc->evq[index];
 
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 
 	KASSERT(rxq->init_state == SFXGE_RXQ_STARTED,
 	    ("rxq not started"));
@@ -849,7 +849,7 @@ again:
 	/* Flush the receive queue */
 	efx_rx_qflush(rxq->common);
 
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 
 	count = 0;
 	do {
@@ -861,7 +861,7 @@ again:
 
 	} while (++count < 20);
 
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 
 	if (rxq->flush_state == SFXGE_FLUSH_FAILED)
 		goto again;
@@ -885,7 +885,7 @@ again:
 	efx_sram_buf_tbl_clear(sc->enp, rxq->buf_base_id,
 	    EFX_RXQ_NBUFS(sc->rxq_entries));
 
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 }
 
 static int
@@ -916,7 +916,7 @@ sfxge_rx_qstart(struct sfxge_softc *sc, 
 	    &rxq->common)) != 0)
 		goto fail;
 
-	mtx_lock(&evq->lock);
+	SFXGE_EVQ_LOCK(evq);
 
 	/* Enable the receive queue. */
 	efx_rx_qenable(rxq->common);
@@ -926,7 +926,7 @@ sfxge_rx_qstart(struct sfxge_softc *sc, 
 	/* Try to fill the queue from the pool. */
 	sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(sc->rxq_entries), B_FALSE);
 
-	mtx_unlock(&evq->lock);
+	SFXGE_EVQ_UNLOCK(evq);
 
 	return (0);
 

Modified: head/sys/dev/sfxge/sfxge_tx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.c	Wed Feb  4 19:58:54 2015	(r278220)
+++ head/sys/dev/sfxge/sfxge_tx.c	Wed Feb  4 20:03:57 2015	(r278221)
@@ -118,7 +118,7 @@ sfxge_tx_qcomplete(struct sfxge_txq *txq
 {
 	unsigned int completed;
 
-	mtx_assert(&evq->lock, MA_OWNED);
+	SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
 
 	completed = txq->completed;
 	while (completed != txq->pending) {
@@ -178,7 +178,7 @@ sfxge_tx_qdpl_swizzle(struct sfxge_txq *
 	unsigned int count;
 	unsigned int non_tcp_count;
 
-	mtx_assert(&txq->lock, MA_OWNED);
+	SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
 	stdp = &txq->dpl;
 
@@ -221,7 +221,7 @@ sfxge_tx_qdpl_swizzle(struct sfxge_txq *
 static void
 sfxge_tx_qreap(struct sfxge_txq *txq)
 {
-	mtx_assert(SFXGE_TXQ_LOCK(txq), MA_OWNED);
+	SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
 	txq->reaped = txq->completed;
 }
@@ -233,7 +233,7 @@ sfxge_tx_qlist_post(struct sfxge_txq *tx
 	unsigned int level;
 	int rc;
 
-	mtx_assert(SFXGE_TXQ_LOCK(txq), MA_OWNED);
+	SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
 	KASSERT(txq->n_pend_desc != 0, ("txq->n_pend_desc == 0"));
 	KASSERT(txq->n_pend_desc <= SFXGE_TSO_MAX_DESC,
@@ -408,7 +408,7 @@ sfxge_tx_qdpl_drain(struct sfxge_txq *tx
 	unsigned int pushed;
 	int rc;
 
-	mtx_assert(&txq->lock, MA_OWNED);
+	SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
 	sc = txq->sc;
 	stdp = &txq->dpl;
@@ -484,7 +484,7 @@ sfxge_tx_qdpl_drain(struct sfxge_txq *tx
 static inline void
 sfxge_tx_qdpl_service(struct sfxge_txq *txq)
 {
-	mtx_assert(&txq->lock, MA_OWNED);
+	SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
 	do {
 		if (SFXGE_TX_QDPL_PENDING(txq))
@@ -493,9 +493,9 @@ sfxge_tx_qdpl_service(struct sfxge_txq *
 		if (!txq->blocked)
 			sfxge_tx_qdpl_drain(txq);
 
-		mtx_unlock(&txq->lock);
+		SFXGE_TXQ_UNLOCK(txq);
 	} while (SFXGE_TX_QDPL_PENDING(txq) &&
-		 mtx_trylock(&txq->lock));
+		 SFXGE_TXQ_TRYLOCK(txq));
 }
 
 /*
@@ -519,7 +519,7 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq,
 	KASSERT(mbuf->m_nextpkt == NULL, ("mbuf->m_nextpkt != NULL"));
 
 	if (locked) {
-		mtx_assert(&txq->lock, MA_OWNED);
+		SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
 		sfxge_tx_qdpl_swizzle(txq);
 
@@ -588,11 +588,11 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 	 * the packet will be appended to the "get list" of the deferred
 	 * packet list.  Otherwise, it will be pushed on the "put list".
 	 */
-	locked = mtx_trylock(&txq->lock);
+	locked = SFXGE_TXQ_TRYLOCK(txq);
 
 	if (sfxge_tx_qdpl_put(txq, m, locked) != 0) {
 		if (locked)
-			mtx_unlock(&txq->lock);
+			SFXGE_TXQ_UNLOCK(txq);
 		rc = ENOBUFS;
 		goto fail;
 	}
@@ -605,7 +605,7 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 	 * is processing the list.
 	 */
 	if (!locked)
-		locked = mtx_trylock(&txq->lock);
+		locked = SFXGE_TXQ_TRYLOCK(txq);
 
 	if (locked) {
 		/* Try to service the list. */
@@ -626,7 +626,7 @@ sfxge_tx_qdpl_flush(struct sfxge_txq *tx
 	struct sfxge_tx_dpl *stdp = &txq->dpl;
 	struct mbuf *mbuf, *next;
 
-	mtx_lock(&txq->lock);
+	SFXGE_TXQ_LOCK(txq);
 
 	sfxge_tx_qdpl_swizzle(txq);
 	for (mbuf = stdp->std_get; mbuf != NULL; mbuf = next) {
@@ -638,7 +638,7 @@ sfxge_tx_qdpl_flush(struct sfxge_txq *tx
 	stdp->std_get_non_tcp_count = 0;
 	stdp->std_getp = &stdp->std_get;
 
-	mtx_unlock(&txq->lock);
+	SFXGE_TXQ_UNLOCK(txq);
 }
 
 void
@@ -753,21 +753,20 @@ void sfxge_if_start(struct ifnet *ifp)
 {
 	struct sfxge_softc *sc = ifp->if_softc;
 
-	mtx_lock(&sc->tx_lock);
+	SFXGE_TXQ_LOCK(sc->txq[0]);
 	sfxge_if_start_locked(ifp);
-	mtx_unlock(&sc->tx_lock);
+	SFXGE_TXQ_UNLOCK(sc->txq[0]);
 }
 
 static inline void
 sfxge_tx_qdpl_service(struct sfxge_txq *txq)
 {
-	struct sfxge_softc *sc = txq->sc;
-	struct ifnet *ifp = sc->ifnet;
+	struct ifnet *ifp = txq->sc->ifnet;
 
-	mtx_assert(&sc->tx_lock, MA_OWNED);
+	SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	sfxge_if_start_locked(ifp);
-	mtx_unlock(&sc->tx_lock);
+	SFXGE_TXQ_UNLOCK(txq);
 }

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list