git: 782db2881b6b - main - cxgbe TOE TLS: Fix handling of unusual record types.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 08 Aug 2022 18:22:25 UTC
The branch main has been updated by jhb:

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

commit 782db2881b6b9c8460f7f311e0e4bbbab36eb88a
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-08-08 18:21:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-08-08 18:21:54 +0000

    cxgbe TOE TLS: Fix handling of unusual record types.
    
    This doesn't matter for real traffic but fixes failures in the KTLS
    unit tests that use unusual record types.
    
    Sponsored by:   Chelsio Communications
---
 sys/dev/cxgbe/tom/t4_tls.c | 14 +++++---------
 sys/dev/cxgbe/tom/t4_tls.h |  2 +-
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/sys/dev/cxgbe/tom/t4_tls.c b/sys/dev/cxgbe/tom/t4_tls.c
index deb0c76836e4..447943b5b9db 100644
--- a/sys/dev/cxgbe/tom/t4_tls.c
+++ b/sys/dev/cxgbe/tom/t4_tls.c
@@ -129,11 +129,6 @@ tls_clr_ofld_mode(struct toepcb *toep)
 static inline unsigned char
 tls_content_type(unsigned char content_type)
 {
-	/*
-	 * XXX: Shouldn't this map CONTENT_TYPE_APP_DATA to DATA and
-	 * default to "CUSTOM" for all other types including
-	 * heartbeat?
-	 */
 	switch (content_type) {
 	case CONTENT_TYPE_CCS:
 		return CPL_TX_TLS_SFO_TYPE_CCS;
@@ -141,10 +136,11 @@ tls_content_type(unsigned char content_type)
 		return CPL_TX_TLS_SFO_TYPE_ALERT;
 	case CONTENT_TYPE_HANDSHAKE:
 		return CPL_TX_TLS_SFO_TYPE_HANDSHAKE;
-	case CONTENT_TYPE_HEARTBEAT:
-		return CPL_TX_TLS_SFO_TYPE_HEARTBEAT;
+	case CONTENT_TYPE_APP_DATA:
+		return CPL_TX_TLS_SFO_TYPE_DATA;
+	default:
+		return CPL_TX_TLS_SFO_TYPE_CUSTOM;
 	}
-	return CPL_TX_TLS_SFO_TYPE_DATA;
 }
 
 /* TLS Key memory management */
@@ -545,7 +541,7 @@ write_tlstx_cpl(struct cpl_tx_tls_sfo *cpl, struct toepcb *toep,
 	    V_CPL_TX_TLS_SFO_DATA_TYPE(data_type) |
 	    V_CPL_TX_TLS_SFO_CPL_LEN(2) | V_CPL_TX_TLS_SFO_SEG_LEN(seglen));
 	cpl->pld_len = htobe32(plen);
-	if (data_type == CPL_TX_TLS_SFO_TYPE_HEARTBEAT)
+	if (data_type == CPL_TX_TLS_SFO_TYPE_CUSTOM)
 		cpl->type_protover = htobe32(
 		    V_CPL_TX_TLS_SFO_TYPE(tls_hdr->type));
 	cpl->seqno_numivs = htobe32(tls_ofld->scmd0.seqno_numivs |
diff --git a/sys/dev/cxgbe/tom/t4_tls.h b/sys/dev/cxgbe/tom/t4_tls.h
index b5b25dd3c6d8..51bf566091e7 100644
--- a/sys/dev/cxgbe/tom/t4_tls.h
+++ b/sys/dev/cxgbe/tom/t4_tls.h
@@ -63,7 +63,7 @@ enum {
 	CPL_TX_TLS_SFO_TYPE_ALERT,
 	CPL_TX_TLS_SFO_TYPE_HANDSHAKE,
 	CPL_TX_TLS_SFO_TYPE_DATA,
-	CPL_TX_TLS_SFO_TYPE_HEARTBEAT,	/* XXX: Shouldn't this be "CUSTOM"? */
+	CPL_TX_TLS_SFO_TYPE_CUSTOM,
 };
 
 struct tls_scmd {