git: d7b47e163dc7 - stable/13 - ktls: Split encrypt vs decrypt OCF counters.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 23 Nov 2021 23:13:14 UTC
The branch stable/13 has been updated by jhb:

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

commit d7b47e163dc7bed63e10e231e0c38451f8787d1b
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2021-11-16 17:58:52 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2021-11-23 23:11:54 +0000

    ktls: Split encrypt vs decrypt OCF counters.
    
    Reviewed by:    gallatin, markj
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D33006
    
    (cherry picked from commit 16bea05ac3275d41663939da0d5c26d89f15cd53)
---
 sys/opencrypto/ktls_ocf.c | 62 +++++++++++++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/sys/opencrypto/ktls_ocf.c b/sys/opencrypto/ktls_ocf.c
index f33af68dde8f..cbd1af6c6341 100644
--- a/sys/opencrypto/ktls_ocf.c
+++ b/sys/opencrypto/ktls_ocf.c
@@ -71,34 +71,44 @@ static SYSCTL_NODE(_kern_ipc_tls_stats, OID_AUTO, ocf,
     CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
     "Kernel TLS offload via OCF stats");
 
-static COUNTER_U64_DEFINE_EARLY(ocf_tls10_cbc_crypts);
-SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls10_cbc_crypts,
-    CTLFLAG_RD, &ocf_tls10_cbc_crypts,
+static COUNTER_U64_DEFINE_EARLY(ocf_tls10_cbc_encrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls10_cbc_encrypts,
+    CTLFLAG_RD, &ocf_tls10_cbc_encrypts,
     "Total number of OCF TLS 1.0 CBC encryption operations");
 
-static COUNTER_U64_DEFINE_EARLY(ocf_tls11_cbc_crypts);
-SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls11_cbc_crypts,
-    CTLFLAG_RD, &ocf_tls11_cbc_crypts,
+static COUNTER_U64_DEFINE_EARLY(ocf_tls11_cbc_encrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls11_cbc_encrypts,
+    CTLFLAG_RD, &ocf_tls11_cbc_encrypts,
     "Total number of OCF TLS 1.1/1.2 CBC encryption operations");
 
-static COUNTER_U64_DEFINE_EARLY(ocf_tls12_gcm_crypts);
-SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls12_gcm_crypts,
-    CTLFLAG_RD, &ocf_tls12_gcm_crypts,
+static COUNTER_U64_DEFINE_EARLY(ocf_tls12_gcm_decrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls12_gcm_decrypts,
+    CTLFLAG_RD, &ocf_tls12_gcm_decrypts,
+    "Total number of OCF TLS 1.2 GCM decryption operations");
+
+static COUNTER_U64_DEFINE_EARLY(ocf_tls12_gcm_encrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls12_gcm_encrypts,
+    CTLFLAG_RD, &ocf_tls12_gcm_encrypts,
     "Total number of OCF TLS 1.2 GCM encryption operations");
 
-static COUNTER_U64_DEFINE_EARLY(ocf_tls12_chacha20_crypts);
-SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls12_chacha20_crypts,
-    CTLFLAG_RD, &ocf_tls12_chacha20_crypts,
+static COUNTER_U64_DEFINE_EARLY(ocf_tls12_chacha20_decrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls12_chacha20_decrypts,
+    CTLFLAG_RD, &ocf_tls12_chacha20_decrypts,
+    "Total number of OCF TLS 1.2 Chacha20-Poly1305 decryption operations");
+
+static COUNTER_U64_DEFINE_EARLY(ocf_tls12_chacha20_encrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls12_chacha20_encrypts,
+    CTLFLAG_RD, &ocf_tls12_chacha20_encrypts,
     "Total number of OCF TLS 1.2 Chacha20-Poly1305 encryption operations");
 
-static COUNTER_U64_DEFINE_EARLY(ocf_tls13_gcm_crypts);
-SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls13_gcm_crypts,
-    CTLFLAG_RD, &ocf_tls13_gcm_crypts,
+static COUNTER_U64_DEFINE_EARLY(ocf_tls13_gcm_encrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls13_gcm_encrypts,
+    CTLFLAG_RD, &ocf_tls13_gcm_encrypts,
     "Total number of OCF TLS 1.3 GCM encryption operations");
 
-static COUNTER_U64_DEFINE_EARLY(ocf_tls13_chacha20_crypts);
-SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls13_chacha20_crypts,
-    CTLFLAG_RD, &ocf_tls13_chacha20_crypts,
+static COUNTER_U64_DEFINE_EARLY(ocf_tls13_chacha20_encrypts);
+SYSCTL_COUNTER_U64(_kern_ipc_tls_stats_ocf, OID_AUTO, tls13_chacha20_encrypts,
+    CTLFLAG_RD, &ocf_tls13_chacha20_encrypts,
     "Total number of OCF TLS 1.3 Chacha20-Poly1305 encryption operations");
 
 static COUNTER_U64_DEFINE_EARLY(ocf_inplace);
@@ -297,9 +307,9 @@ ktls_ocf_tls_cbc_encrypt(struct ktls_session *tls,
 	}
 
 	if (os->implicit_iv)
-		counter_u64_add(ocf_tls10_cbc_crypts, 1);
+		counter_u64_add(ocf_tls10_cbc_encrypts, 1);
 	else
-		counter_u64_add(ocf_tls11_cbc_crypts, 1);
+		counter_u64_add(ocf_tls11_cbc_encrypts, 1);
 	if (inplace)
 		counter_u64_add(ocf_inplace, 1);
 	else
@@ -415,9 +425,9 @@ ktls_ocf_tls12_aead_encrypt(struct ktls_session *tls,
 		crypto_use_output_uio(&crp, &out_uio);
 
 	if (tls->params.cipher_algorithm == CRYPTO_AES_NIST_GCM_16)
-		counter_u64_add(ocf_tls12_gcm_crypts, 1);
+		counter_u64_add(ocf_tls12_gcm_encrypts, 1);
 	else
-		counter_u64_add(ocf_tls12_chacha20_crypts, 1);
+		counter_u64_add(ocf_tls12_chacha20_encrypts, 1);
 	if (inplace)
 		counter_u64_add(ocf_inplace, 1);
 	else
@@ -485,9 +495,9 @@ ktls_ocf_tls12_aead_decrypt(struct ktls_session *tls,
 	crypto_use_mbuf(&crp, m);
 
 	if (tls->params.cipher_algorithm == CRYPTO_AES_NIST_GCM_16)
-		counter_u64_add(ocf_tls12_gcm_crypts, 1);
+		counter_u64_add(ocf_tls12_gcm_decrypts, 1);
 	else
-		counter_u64_add(ocf_tls12_chacha20_crypts, 1);
+		counter_u64_add(ocf_tls12_chacha20_decrypts, 1);
 	error = ktls_ocf_dispatch(os, &crp);
 
 	crypto_destroyreq(&crp);
@@ -576,9 +586,9 @@ ktls_ocf_tls13_aead_encrypt(struct ktls_session *tls,
 	memcpy(crp.crp_iv, nonce, sizeof(nonce));
 
 	if (tls->params.cipher_algorithm == CRYPTO_AES_NIST_GCM_16)
-		counter_u64_add(ocf_tls13_gcm_crypts, 1);
+		counter_u64_add(ocf_tls13_gcm_encrypts, 1);
 	else
-		counter_u64_add(ocf_tls13_chacha20_crypts, 1);
+		counter_u64_add(ocf_tls13_chacha20_encrypts, 1);
 	if (inplace)
 		counter_u64_add(ocf_inplace, 1);
 	else