diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2022-01-04 22:22:12 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2022-01-04 22:22:12 +0000 |
| commit | 74d3f1b63dbea05038e966cf4bb69a01b0589500 (patch) | |
| tree | 642044b727df522541ac07ac39809993d7e7de92 /sys/opencrypto | |
| parent | 753c8513879ba30d129e0b0301ffb8e640231266 (diff) | |
Diffstat (limited to 'sys/opencrypto')
| -rw-r--r-- | sys/opencrypto/crypto.c | 21 | ||||
| -rw-r--r-- | sys/opencrypto/cryptodev.h | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 0ddde1e50899..acc7b8d2ecb8 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -1628,6 +1628,27 @@ crypto_getreq(crypto_session_t cses, int how) } /* + * Clone a crypto request, but associate it with the specified session + * rather than inheriting the session from the original request. The + * fields describing the request buffers are copied, but not the + * opaque field or callback function. + */ +struct cryptop * +crypto_clonereq(struct cryptop *crp, crypto_session_t cses, int how) +{ + struct cryptop *new; + + MPASS((crp->crp_flags & CRYPTO_F_DONE) == 0); + new = crypto_getreq(cses, how); + if (new == NULL) + return (NULL); + + memcpy(&new->crp_startcopy, &crp->crp_startcopy, + __rangeof(struct cryptop, crp_startcopy, crp_endcopy)); + return (new); +} + +/* * Invoke the callback on behalf of the driver. */ void diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index c9638169a8ec..ed396ed86912 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -425,6 +425,7 @@ struct cryptop { * should always check and use the new * value on future requests. */ +#define crp_startcopy crp_flags int crp_flags; #define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */ @@ -457,6 +458,7 @@ struct cryptop { const void *crp_cipher_key; /* New cipher key if non-NULL. */ const void *crp_auth_key; /* New auth key if non-NULL. */ +#define crp_endcopy crp_opaque void *crp_opaque; /* Opaque pointer, passed along */ @@ -622,6 +624,8 @@ void crypto_dispatch_batch(struct cryptopq *crpq, int flags); int crypto_unblock(uint32_t, int); void crypto_done(struct cryptop *crp); +struct cryptop *crypto_clonereq(struct cryptop *crp, crypto_session_t cses, + int how); void crypto_destroyreq(struct cryptop *crp); void crypto_initreq(struct cryptop *crp, crypto_session_t cses); void crypto_freereq(struct cryptop *crp); |
