Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 May 2015 09:11:04 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r283210 - stable/10/sys/dev/sfxge
Message-ID:  <201505210911.t4L9B43P071445@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Thu May 21 09:11:03 2015
New Revision: 283210
URL: https://svnweb.freebsd.org/changeset/base/283210

Log:
  MFC: r282997
  
  sfxge: get rid of locked variable in sfxge_tx_packet_add()
  
  Now each branch has one and only one possible TxQ lock state.
  It simplifies understanding of the code.
  
  Sponsored by:   Solarflare Communications, Inc.

Modified:
  stable/10/sys/dev/sfxge/sfxge_tx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sfxge/sfxge_tx.c
==============================================================================
--- stable/10/sys/dev/sfxge/sfxge_tx.c	Thu May 21 09:09:51 2015	(r283209)
+++ stable/10/sys/dev/sfxge/sfxge_tx.c	Thu May 21 09:11:03 2015	(r283210)
@@ -602,7 +602,6 @@ sfxge_tx_qdpl_put_unlocked(struct sfxge_
 int
 sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
 {
-	int locked;
 	int rc;
 
 	if (!SFXGE_LINK_UP(txq->sc)) {
@@ -616,9 +615,7 @@ 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 = SFXGE_TXQ_TRYLOCK(txq);
-
-	if (locked) {
+	if (SFXGE_TXQ_TRYLOCK(txq)) {
 		/* First swizzle put-list to get-list to keep order */
 		sfxge_tx_qdpl_swizzle(txq);
 
@@ -627,6 +624,10 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 			SFXGE_TXQ_UNLOCK(txq);
 			goto fail;
 		}
+
+		/* Try to service the list. */
+		sfxge_tx_qdpl_service(txq);
+		/* Lock has been dropped. */
 	} else {
 		rc = sfxge_tx_qdpl_put_unlocked(txq, m);
 		if (rc != 0)
@@ -639,14 +640,13 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 		 * the deferred packet list.  If we are not able to get
 		 * the lock, another thread is processing the list.
 		 */
-		locked = SFXGE_TXQ_TRYLOCK(txq);
+		if (SFXGE_TXQ_TRYLOCK(txq)) {
+			sfxge_tx_qdpl_service(txq);
+			/* Lock has been dropped. */
+		}
 	}
 
-	if (locked) {
-		/* Try to service the list. */
-		sfxge_tx_qdpl_service(txq);
-		/* Lock has been dropped. */
-	}
+	SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
 
 	return (0);
 



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