git: b33ff94123a6 - main - ktls: Change struct ktls_session.cipher to an OCF-specific type.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 21 Oct 2021 17:08:55 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b33ff94123a666d0f38541f97f1c64c512f90a56 commit b33ff94123a666d0f38541f97f1c64c512f90a56 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2021-10-21 16:36:53 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2021-10-21 16:36:53 +0000 ktls: Change struct ktls_session.cipher to an OCF-specific type. As a followup to SW KTLS assuming an OCF backend, rename struct ocf_session to struct ktls_ocf_session and forward declare it in <sys/ktls.h> to use as the type of struct ktls_session.cipher. Reviewed by: gallatin, hselasky Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32565 --- sys/opencrypto/ktls_ocf.c | 30 +++++++++++++++--------------- sys/sys/ktls.h | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/sys/opencrypto/ktls_ocf.c b/sys/opencrypto/ktls_ocf.c index a3b9ab49e4f0..0753f4bafb1a 100644 --- a/sys/opencrypto/ktls_ocf.c +++ b/sys/opencrypto/ktls_ocf.c @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include <opencrypto/cryptodev.h> #include <opencrypto/ktls.h> -struct ocf_session { +struct ktls_ocf_session { crypto_session_t sid; crypto_session_t mac_sid; struct mtx lock; @@ -64,7 +64,7 @@ struct ocf_session { }; struct ocf_operation { - struct ocf_session *os; + struct ktls_ocf_session *os; bool done; }; @@ -142,7 +142,7 @@ ktls_ocf_callback_async(struct cryptop *crp) } static int -ktls_ocf_dispatch(struct ocf_session *os, struct cryptop *crp) +ktls_ocf_dispatch(struct ktls_ocf_session *os, struct cryptop *crp) { struct ocf_operation oo; int error; @@ -228,7 +228,7 @@ ktls_ocf_tls_cbc_encrypt(struct ktls_ocf_encrypt_state *state, struct uio *uio; struct tls_mac_data *ad; struct cryptop *crp; - struct ocf_session *os; + struct ktls_ocf_session *os; struct iovec iov[m->m_epg_npgs + 2]; u_int pgoff; int i, error; @@ -237,7 +237,7 @@ ktls_ocf_tls_cbc_encrypt(struct ktls_ocf_encrypt_state *state, MPASS(outiovcnt + 1 <= nitems(iov)); - os = tls->cipher; + os = tls->ocf_session; hdr = (const struct tls_record_layer *)m->m_epg_hdr; crp = &state->crp; uio = &state->uio; @@ -376,11 +376,11 @@ ktls_ocf_tls12_aead_encrypt(struct ktls_ocf_encrypt_state *state, struct uio *uio; struct tls_aead_data *ad; struct cryptop *crp; - struct ocf_session *os; + struct ktls_ocf_session *os; int error; uint16_t tls_comp_len; - os = tls->cipher; + os = tls->ocf_session; hdr = (const struct tls_record_layer *)m->m_epg_hdr; crp = &state->crp; uio = &state->uio; @@ -457,12 +457,12 @@ ktls_ocf_tls12_aead_decrypt(struct ktls_session *tls, { struct tls_aead_data ad; struct cryptop crp; - struct ocf_session *os; + struct ktls_ocf_session *os; struct ocf_operation oo; int error; uint16_t tls_comp_len; - os = tls->cipher; + os = tls->ocf_session; oo.os = os; oo.done = false; @@ -526,11 +526,11 @@ ktls_ocf_tls13_aead_encrypt(struct ktls_ocf_encrypt_state *state, struct uio *uio; struct tls_aead_data_13 *ad; struct cryptop *crp; - struct ocf_session *os; + struct ktls_ocf_session *os; char nonce[12]; int error; - os = tls->cipher; + os = tls->ocf_session; hdr = (const struct tls_record_layer *)m->m_epg_hdr; crp = &state->crp; uio = &state->uio; @@ -598,9 +598,9 @@ ktls_ocf_tls13_aead_encrypt(struct ktls_ocf_encrypt_state *state, void ktls_ocf_free(struct ktls_session *tls) { - struct ocf_session *os; + struct ktls_ocf_session *os; - os = tls->cipher; + os = tls->ocf_session; crypto_freesession(os->sid); mtx_destroy(&os->lock); zfree(os, M_KTLS_OCF); @@ -610,7 +610,7 @@ int ktls_ocf_try(struct socket *so, struct ktls_session *tls, int direction) { struct crypto_session_params csp, mac_csp; - struct ocf_session *os; + struct ktls_ocf_session *os; int error, mac_len; memset(&csp, 0, sizeof(csp)); @@ -745,7 +745,7 @@ ktls_ocf_try(struct socket *so, struct ktls_session *tls, int direction) } mtx_init(&os->lock, "ktls_ocf", NULL, MTX_DEF); - tls->cipher = os; + tls->ocf_session = os; if (tls->params.cipher_algorithm == CRYPTO_AES_NIST_GCM_16 || tls->params.cipher_algorithm == CRYPTO_CHACHA20_POLY1305) { if (direction == KTLS_TX) { diff --git a/sys/sys/ktls.h b/sys/sys/ktls.h index 4258d2c342dc..aea13d2d8ce1 100644 --- a/sys/sys/ktls.h +++ b/sys/sys/ktls.h @@ -167,6 +167,7 @@ struct tls_session_params { #define KTLS_RX 2 struct iovec; +struct ktls_ocf_session; struct ktls_ocf_encrypt_state; struct ktls_session; struct m_snd_tag; @@ -184,7 +185,7 @@ struct ktls_session { uint64_t seqno, int *trailer_len); }; union { - void *cipher; + struct ktls_ocf_session *ocf_session; struct m_snd_tag *snd_tag; }; struct tls_session_params params;