git: aee8d42a37ac - stable/14 - cxgbe nic TLS: Fix requests with 8 bytes of immediate data padding

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 29 Jan 2026 15:39:53 UTC
The branch stable/14 has been updated by jhb:

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

commit aee8d42a37ac34e20af6b4b4a890e7221d200330
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-05-13 13:57:18 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-01-29 15:17:47 +0000

    cxgbe nic TLS: Fix requests with 8 bytes of immediate data padding
    
    Requests whose immediate data do not end on a 16-byte boundary are
    padded with zeroes before the next WR command.  Since ULP commands are
    8 byte aligned, if there are more than 8 bytes of padding, the
    immediate data is padded with zeroes up to an 8 byte boundary and the
    last 8 bytes contain a ULP NOOP command.
    
    In the case of exactly 8 bytes of padding, the result should be that
    no zeroes are inserted, only the ULP NOOP.  However, the code was
    actually inserting 8 bytes of zero padding followed by the ULP NOOP
    causing the following real command to be misaligned.  Fix this by
    skipping the zero padding if there exactly 8 padding bytes.
    
    Reported by:    Sony Arpita Das @ Chelsio
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 2befd06588325c541d400fcc4915a1adfd1c7d17)
---
 sys/dev/cxgbe/crypto/t6_kern_tls.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/dev/cxgbe/crypto/t6_kern_tls.c b/sys/dev/cxgbe/crypto/t6_kern_tls.c
index 2173cb670874..0e7bd305869b 100644
--- a/sys/dev/cxgbe/crypto/t6_kern_tls.c
+++ b/sys/dev/cxgbe/crypto/t6_kern_tls.c
@@ -1794,9 +1794,11 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq *txq, void *dst,
 	}
 
 	if (imm_len % 16 != 0) {
-		/* Zero pad to an 8-byte boundary. */
-		memset(out, 0, 8 - (imm_len % 8));
-		out += 8 - (imm_len % 8);
+		if (imm_len % 8 != 0) {
+			/* Zero pad to an 8-byte boundary. */
+			memset(out, 0, 8 - (imm_len % 8));
+			out += 8 - (imm_len % 8);
+		}
 
 		/*
 		 * Insert a ULP_TX_SC_NOOP if needed so the SGL is