diff options
author | John Baldwin <jhb@FreeBSD.org> | 2020-06-09 22:26:07 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2020-06-09 22:26:07 +0000 |
commit | a3d565a1188f2e57bf70e2949d353d27ef1f1606 (patch) | |
tree | 3696febeb36180b72cf90e2ff6d8bd64c53aee4f /sys/geom | |
parent | cea399ec0e2b42e187de40f844afda39ad264c97 (diff) | |
download | src-test-a3d565a1188f2e57bf70e2949d353d27ef1f1606.tar.gz src-test-a3d565a1188f2e57bf70e2949d353d27ef1f1606.zip |
Notes
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/eli/g_eli.c | 26 | ||||
-rw-r--r-- | sys/geom/eli/g_eli.h | 1 |
2 files changed, 17 insertions, 10 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 2a7076c0fd28b..8e7433f23594e 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -489,7 +489,8 @@ g_eli_newsession(struct g_eli_worker *wr) { struct g_eli_softc *sc; struct crypto_session_params csp; - int error; + uint32_t caps; + int error, new_crypto; void *key; sc = wr->w_softc; @@ -516,6 +517,7 @@ g_eli_newsession(struct g_eli_worker *wr) } switch (sc->sc_crypto) { + case G_ELI_CRYPTO_SW_ACCEL: case G_ELI_CRYPTO_SW: error = crypto_newsession(&wr->w_sid, &csp, CRYPTOCAP_F_SOFTWARE); @@ -526,18 +528,18 @@ g_eli_newsession(struct g_eli_worker *wr) break; case G_ELI_CRYPTO_UNKNOWN: error = crypto_newsession(&wr->w_sid, &csp, - CRYPTOCAP_F_HARDWARE); + CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE); if (error == 0) { + caps = crypto_ses2caps(wr->w_sid); + if (caps & CRYPTOCAP_F_HARDWARE) + new_crypto = G_ELI_CRYPTO_HW; + else if (caps & CRYPTOCAP_F_ACCEL_SOFTWARE) + new_crypto = G_ELI_CRYPTO_SW_ACCEL; + else + new_crypto = G_ELI_CRYPTO_SW; mtx_lock(&sc->sc_queue_mtx); if (sc->sc_crypto == G_ELI_CRYPTO_UNKNOWN) - sc->sc_crypto = G_ELI_CRYPTO_HW; - mtx_unlock(&sc->sc_queue_mtx); - } else { - error = crypto_newsession(&wr->w_sid, &csp, - CRYPTOCAP_F_SOFTWARE); - mtx_lock(&sc->sc_queue_mtx); - if (sc->sc_crypto == G_ELI_CRYPTO_UNKNOWN) - sc->sc_crypto = G_ELI_CRYPTO_SW; + sc->sc_crypto = new_crypto; mtx_unlock(&sc->sc_queue_mtx); } break; @@ -983,6 +985,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp, if (sc->sc_flags & G_ELI_FLAG_AUTH) G_ELI_DEBUG(0, " Integrity: %s", g_eli_algo2str(sc->sc_aalgo)); G_ELI_DEBUG(0, " Crypto: %s", + sc->sc_crypto == G_ELI_CRYPTO_SW_ACCEL ? "accelerated software" : sc->sc_crypto == G_ELI_CRYPTO_SW ? "software" : "hardware"); return (gp); failed: @@ -1381,6 +1384,9 @@ g_eli_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, case G_ELI_CRYPTO_SW: sbuf_cat(sb, "software"); break; + case G_ELI_CRYPTO_SW_ACCEL: + sbuf_cat(sb, "accelerated software"); + break; default: sbuf_cat(sb, "UNKNOWN"); break; diff --git a/sys/geom/eli/g_eli.h b/sys/geom/eli/g_eli.h index 1853aa17dbc12..e66bdaf409b6c 100644 --- a/sys/geom/eli/g_eli.h +++ b/sys/geom/eli/g_eli.h @@ -145,6 +145,7 @@ #define G_ELI_CRYPTO_UNKNOWN 0 #define G_ELI_CRYPTO_HW 1 #define G_ELI_CRYPTO_SW 2 +#define G_ELI_CRYPTO_SW_ACCEL 3 #ifdef _KERNEL #if (MAX_KEY_BYTES < G_ELI_DATAIVKEYLEN) |