git: bbb2f537156b - main - cxgbe: Rename t4_kern_tls.c to t6_kern_tls.c.

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

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

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

    cxgbe: Rename t4_kern_tls.c to t6_kern_tls.c.
    
    This implementation of NIC TLS is specific to T6 adapters.
    
    Sponsored by:   Chelsio Communications
---
 sys/conf/files                                     |  2 +-
 sys/dev/cxgbe/adapter.h                            |  4 +-
 .../cxgbe/crypto/{t4_kern_tls.c => t6_kern_tls.c}  | 14 +++---
 sys/dev/cxgbe/t4_main.c                            | 50 ++++++++++++++--------
 sys/modules/cxgbe/if_cxgbe/Makefile                |  2 +-
 5 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/sys/conf/files b/sys/conf/files
index 0bfd6c147203..bca5c127b525 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1459,7 +1459,7 @@ dev/cxgbe/common/t4_hw.c	optional cxgbe pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
 dev/cxgbe/common/t4vf_hw.c	optional cxgbev pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
-dev/cxgbe/crypto/t4_kern_tls.c	optional cxgbe pci kern_tls \
+dev/cxgbe/crypto/t6_kern_tls.c	optional cxgbe pci kern_tls \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
 dev/cxgbe/crypto/t4_keyctx.c	optional cxgbe pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 637fee6b4a78..555f8b36531d 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -1299,8 +1299,8 @@ void cxgbe_media_status(struct ifnet *, struct ifmediareq *);
 void t4_os_cim_err(struct adapter *);
 
 #ifdef KERN_TLS
-/* t4_kern_tls.c */
-int cxgbe_tls_tag_alloc(struct ifnet *, union if_snd_tag_alloc_params *,
+/* t6_kern_tls.c */
+int t6_tls_tag_alloc(struct ifnet *, union if_snd_tag_alloc_params *,
     struct m_snd_tag **);
 void t6_ktls_modload(void);
 void t6_ktls_modunload(void);
diff --git a/sys/dev/cxgbe/crypto/t4_kern_tls.c b/sys/dev/cxgbe/crypto/t6_kern_tls.c
similarity index 99%
rename from sys/dev/cxgbe/crypto/t4_kern_tls.c
rename to sys/dev/cxgbe/crypto/t6_kern_tls.c
index 725d15e9cb35..1374530f941f 100644
--- a/sys/dev/cxgbe/crypto/t4_kern_tls.c
+++ b/sys/dev/cxgbe/crypto/t6_kern_tls.c
@@ -102,12 +102,12 @@ struct tlspcb {
 	bool open_pending;
 };
 
-static void cxgbe_tls_tag_free(struct m_snd_tag *mst);
+static void t6_tls_tag_free(struct m_snd_tag *mst);
 static int ktls_setup_keys(struct tlspcb *tlsp,
     const struct ktls_session *tls, struct sge_txq *txq);
 
-static const struct if_snd_tag_sw cxgbe_tls_tag_sw = {
-	.snd_tag_free = cxgbe_tls_tag_free,
+static const struct if_snd_tag_sw t6_tls_tag_sw = {
+	.snd_tag_free = t6_tls_tag_free,
 	.type = IF_SND_TAG_TYPE_TLS
 };
 
@@ -128,7 +128,7 @@ alloc_tlspcb(struct ifnet *ifp, struct vi_info *vi, int flags)
 	if (tlsp == NULL)
 		return (NULL);
 
-	m_snd_tag_init(&tlsp->com, ifp, &cxgbe_tls_tag_sw);
+	m_snd_tag_init(&tlsp->com, ifp, &t6_tls_tag_sw);
 	tlsp->vi = vi;
 	tlsp->sc = sc;
 	tlsp->ctrlq = &sc->sge.ctrlq[pi->port_id];
@@ -373,7 +373,7 @@ ktls_set_tcb_fields(struct tlspcb *tlsp, struct tcpcb *tp, struct sge_txq *txq)
 }
 
 int
-cxgbe_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
+t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
     struct m_snd_tag **pt)
 {
 	const struct ktls_session *tls;
@@ -2078,7 +2078,7 @@ t6_ktls_write_wr(struct sge_txq *txq, void *dst, struct mbuf *m, u_int nsegs,
 }
 
 static void
-cxgbe_tls_tag_free(struct m_snd_tag *mst)
+t6_tls_tag_free(struct m_snd_tag *mst)
 {
 	struct adapter *sc;
 	struct tlspcb *tlsp;
@@ -2119,7 +2119,7 @@ t6_ktls_modunload(void)
 #else
 
 int
-cxgbe_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
+t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
     struct m_snd_tag **pt)
 {
 	return (ENXIO);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 20d69c06f779..27403b681208 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -686,7 +686,7 @@ SYSCTL_INT(_hw_cxgbe, OID_AUTO, cop_managed_offloading, CTLFLAG_RDTUN,
  */
 static int t4_kern_tls = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, kern_tls, CTLFLAG_RDTUN, &t4_kern_tls, 0,
-    "Enable KERN_TLS mode for all supported adapters");
+    "Enable KERN_TLS mode for T6 adapters");
 
 SYSCTL_NODE(_hw_cxgbe, OID_AUTO, tls, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
     "cxgbe(4) KERN_TLS parameters");
@@ -1840,7 +1840,10 @@ ok_to_reset(struct adapter *sc)
 	struct port_info *pi;
 	struct vi_info *vi;
 	int i, j;
-	const int caps = IFCAP_TOE | IFCAP_TXTLS | IFCAP_NETMAP | IFCAP_TXRTLMT;
+	int caps = IFCAP_TOE | IFCAP_NETMAP | IFCAP_TXRTLMT;
+
+	if (is_t6(sc))
+		caps |= IFCAP_TXTLS;
 
 	ASSERT_SYNCHRONIZED_OP(sc);
 	MPASS(!(sc->flags & IS_VF));
@@ -2554,7 +2557,7 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 #ifdef KERN_TLS
 	if (is_ktls(sc)) {
 		ifp->if_capabilities |= IFCAP_TXTLS;
-		if (sc->flags & KERN_TLS_ON)
+		if (sc->flags & KERN_TLS_ON || !is_t6(sc))
 			ifp->if_capenable |= IFCAP_TXTLS;
 	}
 #endif
@@ -3162,8 +3165,15 @@ cxgbe_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
 #endif
 #ifdef KERN_TLS
 	case IF_SND_TAG_TYPE_TLS:
-		error = cxgbe_tls_tag_alloc(ifp, params, pt);
+	{
+		struct vi_info *vi = ifp->if_softc;
+
+		if (is_t6(vi->pi->adapter))
+			error = t6_tls_tag_alloc(ifp, params, pt);
+		else
+			error = EOPNOTSUPP;
 		break;
+	}
 #endif
 	default:
 		error = EOPNOTSUPP;
@@ -5508,7 +5518,7 @@ ktls_tick(void *arg)
 }
 
 static int
-t4_config_kern_tls(struct adapter *sc, bool enable)
+t6_config_kern_tls(struct adapter *sc, bool enable)
 {
 	int rc;
 	uint32_t param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
@@ -5654,12 +5664,13 @@ set_params__post_init(struct adapter *sc)
 		 */
 		t4_tp_wr_bits_indirect(sc, A_TP_FRAG_CONFIG,
 		    V_PASSMODE(M_PASSMODE), V_PASSMODE(2));
-		if (is_ktls(sc)) {
-			sc->tlst.inline_keys = t4_tls_inline_keys;
-			sc->tlst.combo_wrs = t4_tls_combo_wrs;
-			if (t4_kern_tls != 0)
-				t4_config_kern_tls(sc, true);
-		}
+	}
+
+	if (is_ktls(sc)) {
+		sc->tlst.inline_keys = t4_tls_inline_keys;
+		sc->tlst.combo_wrs = t4_tls_combo_wrs;
+		if (t4_kern_tls != 0 && is_t6(sc))
+			t6_config_kern_tls(sc, true);
 	}
 #endif
 	return (0);
@@ -7540,9 +7551,12 @@ t4_sysctls(struct adapter *sc)
 		    CTLFLAG_RW, &sc->tlst.inline_keys, 0, "Always pass TLS "
 		    "keys in work requests (1) or attempt to store TLS keys "
 		    "in card memory.");
-		SYSCTL_ADD_INT(ctx, children, OID_AUTO, "combo_wrs",
-		    CTLFLAG_RW, &sc->tlst.combo_wrs, 0, "Attempt to combine "
-		    "TCB field updates with TLS record work requests.");
+
+		if (is_t6(sc))
+			SYSCTL_ADD_INT(ctx, children, OID_AUTO, "combo_wrs",
+			    CTLFLAG_RW, &sc->tlst.combo_wrs, 0, "Attempt to "
+			    "combine TCB field updates with TLS record work "
+			    "requests.");
 	}
 #endif
 
@@ -12395,7 +12409,7 @@ toe_capability(struct vi_info *vi, bool enable)
 
 	if (enable) {
 #ifdef KERN_TLS
-		if (sc->flags & KERN_TLS_ON) {
+		if (sc->flags & KERN_TLS_ON && is_t6(sc)) {
 			int i, j, n;
 			struct port_info *p;
 			struct vi_info *v;
@@ -12422,7 +12436,7 @@ toe_capability(struct vi_info *vi, bool enable)
 				    "trying to enable TOE.\n");
 				return (EAGAIN);
 			}
-			rc = t4_config_kern_tls(sc, false);
+			rc = t6_config_kern_tls(sc, false);
 			if (rc)
 				return (rc);
 		}
@@ -12665,6 +12679,8 @@ ktls_capability(struct adapter *sc, bool enable)
 
 	if (!is_ktls(sc))
 		return (ENODEV);
+	if (!is_t6(sc))
+		return (0);
 	if (hw_off_limits(sc))
 		return (ENXIO);
 
@@ -12677,7 +12693,7 @@ ktls_capability(struct adapter *sc, bool enable)
 			    "this adapter before trying to enable NIC TLS.\n");
 			return (EAGAIN);
 		}
-		return (t4_config_kern_tls(sc, true));
+		return (t6_config_kern_tls(sc, true));
 	} else {
 		/*
 		 * Nothing to do for disable.  If TOE is enabled sometime later
diff --git a/sys/modules/cxgbe/if_cxgbe/Makefile b/sys/modules/cxgbe/if_cxgbe/Makefile
index 7210d4e8835e..723029264bac 100644
--- a/sys/modules/cxgbe/if_cxgbe/Makefile
+++ b/sys/modules/cxgbe/if_cxgbe/Makefile
@@ -24,7 +24,7 @@ SRCS+=	t4_hw.c
 SRCS+=	t4_if.c t4_if.h
 SRCS+=	t4_iov.c
 .if ${KERN_OPTS:MKERN_TLS} != ""
-SRCS+=	t4_kern_tls.c
+SRCS+=	t6_kern_tls.c
 .endif
 SRCS+=	t4_keyctx.c
 SRCS+=	t4_l2t.c