aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/crypto/internal/acompress.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2025-04-07 18:03:00 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2025-04-16 15:16:20 +0800
commit097c432caaa6d91f87732fe991cb08139e31101a (patch)
treecbf90c936c17accd824b0f16e4bc7210f6eb02ef /include/crypto/internal/acompress.h
parentcrypto: iaa - Switch to ACOMP_FBREQ_ON_STACK (diff)
downloadwireguard-linux-097c432caaa6d91f87732fe991cb08139e31101a.tar.xz
wireguard-linux-097c432caaa6d91f87732fe991cb08139e31101a.zip
crypto: acomp - Add ACOMP_REQUEST_CLONE
Add a new helper ACOMP_REQUEST_CLONE that will transform a stack request into a dynamically allocated one if possible, and otherwise switch it over to the sycnrhonous fallback transform. The intended usage is: ACOMP_STACK_ON_REQUEST(req, tfm); ... err = crypto_acomp_compress(req); /* The request cannot complete synchronously. */ if (err == -EAGAIN) { /* This will not fail. */ req = ACOMP_REQUEST_CLONE(req, gfp); /* Redo operation. */ err = crypto_acomp_compress(req); } Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto/internal/acompress.h')
-rw-r--r--include/crypto/internal/acompress.h11
1 files changed, 3 insertions, 8 deletions
diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h
index 8840fd2c1db5..b51d66633935 100644
--- a/include/crypto/internal/acompress.h
+++ b/include/crypto/internal/acompress.h
@@ -17,12 +17,6 @@
#include <linux/spinlock.h>
#include <linux/workqueue_types.h>
-#define ACOMP_REQUEST_ON_STACK(name, tfm) \
- char __##name##_req[sizeof(struct acomp_req) + \
- MAX_SYNC_COMP_REQSIZE] CRYPTO_MINALIGN_ATTR; \
- struct acomp_req *name = acomp_request_on_stack_init( \
- __##name##_req, (tfm), 0, true)
-
#define ACOMP_FBREQ_ON_STACK(name, req) \
char __##name##_req[sizeof(struct acomp_req) + \
MAX_SYNC_COMP_REQSIZE] CRYPTO_MINALIGN_ATTR; \
@@ -245,9 +239,10 @@ static inline struct acomp_req *acomp_fbreq_on_stack_init(
char *buf, struct acomp_req *old)
{
struct crypto_acomp *tfm = crypto_acomp_reqtfm(old);
- struct acomp_req *req;
+ struct acomp_req *req = (void *)buf;
- req = acomp_request_on_stack_init(buf, tfm, 0, true);
+ acomp_request_set_tfm(req, tfm->fb);
+ req->base.flags = CRYPTO_TFM_REQ_ON_STACK;
acomp_request_set_callback(req, acomp_request_flags(old), NULL, NULL);
req->base.flags &= ~CRYPTO_ACOMP_REQ_PRIVATE;
req->base.flags |= old->base.flags & CRYPTO_ACOMP_REQ_PRIVATE;