git: 07f47e8850d0 - main - cxgbe/t4_tom: completely avoid L2T entries during stop/suspend.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Mon, 16 Sep 2024 19:00:14 UTC
The branch main has been updated by np:

URL: https://cgit.FreeBSD.org/src/commit/?id=07f47e8850d0639d474026b203013072aeb32c81

commit 07f47e8850d0639d474026b203013072aeb32c81
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-09-14 04:23:23 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-09-16 17:24:32 +0000

    cxgbe/t4_tom: completely avoid L2T entries during stop/suspend.
    
    1. Mark the L2T entry valid only if t4_write_l2e succeeds, which won't
       happen if the adapter is stopped.  This prevents L2T entries from
       sometimes getting (re)promoted to VALID on Tx activity during stop.
    2. Discard a work request immediately instead of enqueueing it to the
       arp queue if the adapter is stopped.
    
    Fixes:  c1c524852f62 cxgbe/t4_tom: Implement uld_stop and uld_restart for ULD_TOM.
    MFC after:      1 week
    Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/tom/t4_tom_l2t.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/sys/dev/cxgbe/tom/t4_tom_l2t.c b/sys/dev/cxgbe/tom/t4_tom_l2t.c
index 749e5704863e..be42a887323f 100644
--- a/sys/dev/cxgbe/tom/t4_tom_l2t.c
+++ b/sys/dev/cxgbe/tom/t4_tom_l2t.c
@@ -212,20 +212,18 @@ update_entry(struct adapter *sc, struct l2t_entry *e, uint8_t *lladdr,
 
 		e->state = L2T_STATE_STALE;
 
-	} else {
-
-		if (e->state == L2T_STATE_RESOLVING ||
-		    e->state == L2T_STATE_FAILED ||
-		    memcmp(e->dmac, lladdr, ETHER_ADDR_LEN)) {
+	} else if (e->state == L2T_STATE_RESOLVING ||
+	    e->state == L2T_STATE_FAILED ||
+	    memcmp(e->dmac, lladdr, ETHER_ADDR_LEN)) {
 
-			/* unresolved -> resolved; or dmac changed */
+		/* unresolved -> resolved; or dmac changed */
 
-			memcpy(e->dmac, lladdr, ETHER_ADDR_LEN);
-			e->vlan = vtag;
-			t4_write_l2e(e, 1);
-		}
+		memcpy(e->dmac, lladdr, ETHER_ADDR_LEN);
+		e->vlan = vtag;
+		if (t4_write_l2e(e, 1) == 0)
+			e->state = L2T_STATE_VALID;
+	} else
 		e->state = L2T_STATE_VALID;
-	}
 }
 
 static int
@@ -291,7 +289,10 @@ again:
 			mtx_unlock(&e->lock);
 			goto again;
 		}
-		arpq_enqueue(e, wr);
+		if (adapter_stopped(sc))
+			free(wr, M_CXGBE);
+		else
+			arpq_enqueue(e, wr);
 		mtx_unlock(&e->lock);
 
 		if (resolve_entry(sc, e) == EWOULDBLOCK)