git: a4cd88b604de - main - cxgbe: Add ULD_NVME for NVMe/TCP offload

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 10 Nov 2025 15:51:27 UTC
The branch main has been updated by jhb:

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

commit a4cd88b604def2b59b0871e612bd6ad04b22520e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-11-10 15:50:47 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-11-10 15:50:47 +0000

    cxgbe: Add ULD_NVME for NVMe/TCP offload
    
    NVMe/TCP offload depends on TOE similar to iSCSI and iWARP offloads.
    
    Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/offload.h    | 3 ++-
 sys/dev/cxgbe/t4_main.c    | 7 ++++++-
 sys/dev/cxgbe/tom/t4_tom.c | 6 ++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/sys/dev/cxgbe/offload.h b/sys/dev/cxgbe/offload.h
index 91a43785aaca..d63accf86e2a 100644
--- a/sys/dev/cxgbe/offload.h
+++ b/sys/dev/cxgbe/offload.h
@@ -196,7 +196,8 @@ enum {
 	ULD_TOM = 0,
 	ULD_IWARP,
 	ULD_ISCSI,
-	ULD_MAX = ULD_ISCSI
+	ULD_NVME,
+	ULD_MAX = ULD_NVME
 };
 
 struct adapter;
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 5bc503e48bf2..4d9c94789a37 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -13412,11 +13412,16 @@ toe_capability(struct vi_info *vi, bool enable)
 			    ("%s: TOM activated but flag not set", __func__));
 		}
 
-		/* Activate iWARP and iSCSI too, if the modules are loaded. */
+		/*
+		 * Activate iWARP, iSCSI, and NVMe too, if the modules
+		 * are loaded.
+		 */
 		if (!uld_active(sc, ULD_IWARP))
 			(void) t4_activate_uld(sc, ULD_IWARP);
 		if (!uld_active(sc, ULD_ISCSI))
 			(void) t4_activate_uld(sc, ULD_ISCSI);
+		if (!uld_active(sc, ULD_NVME))
+			(void) t4_activate_uld(sc, ULD_NVME);
 
 		if (pi->uld_vis++ == 0)
 			setbit(&sc->offload_map, pi->port_id);
diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index 53a945f8b4cc..8dfffd465345 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -1990,8 +1990,10 @@ t4_tom_deactivate(struct adapter *sc)
 	if (td == NULL)
 		return (0);	/* XXX. KASSERT? */
 
-	if (uld_active(sc, ULD_IWARP) || uld_active(sc, ULD_ISCSI))
-		return (EBUSY);	/* both iWARP and iSCSI rely on the TOE. */
+	/* These ULDs rely on the TOE. */
+	if (uld_active(sc, ULD_IWARP) || uld_active(sc, ULD_ISCSI) ||
+	    uld_active(sc, ULD_NVME))
+		return (EBUSY);
 
 	if (sc->offload_map != 0) {
 		for_each_port(sc, i) {