summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarybchik <arybchik@FreeBSD.org>2015-05-21 09:11:03 +0000
committerarybchik <arybchik@FreeBSD.org>2015-05-21 09:11:03 +0000
commita53d333e88fdff44c4a763c081f2e705747b8870 (patch)
treea20206c48a3c54998b0350db13b87b3e73a4e4d9
parentd7d6b9f862b4f9b9567df5a9c518c9c1d4ef2041 (diff)
downloadFreeBSD-src-a53d333e88fdff44c4a763c081f2e705747b8870.zip
FreeBSD-src-a53d333e88fdff44c4a763c081f2e705747b8870.tar.gz
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.
-rw-r--r--sys/dev/sfxge/sfxge_tx.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c
index 862d144..375fc7c 100644
--- a/sys/dev/sfxge/sfxge_tx.c
+++ b/sys/dev/sfxge/sfxge_tx.c
@@ -602,7 +602,6 @@ sfxge_tx_qdpl_put_unlocked(struct sfxge_txq *txq, struct mbuf *mbuf)
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 *txq, struct mbuf *m)
* 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 *txq, struct mbuf *m)
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 *txq, struct mbuf *m)
* 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);
OpenPOWER on IntegriCloud