hc
2024-02-19 151fecfb72a0d602dfe79790602ef64b4e241574
kernel/include/crypto/acompress.h
....@@ -1,15 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Asynchronous Compression operations
34 *
45 * Copyright (c) 2016, Intel Corporation
56 * Authors: Weigang Li <weigang.li@intel.com>
67 * Giovanni Cabiddu <giovanni.cabiddu@intel.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the Free
10
- * Software Foundation; either version 2 of the License, or (at your option)
11
- * any later version.
12
- *
138 */
149 #ifndef _CRYPTO_ACOMP_H
1510 #define _CRYPTO_ACOMP_H
....@@ -111,6 +106,24 @@
111106 */
112107 struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
113108 u32 mask);
109
+/**
110
+ * crypto_alloc_acomp_node() -- allocate ACOMPRESS tfm handle with desired NUMA node
111
+ * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
112
+ * compression algorithm e.g. "deflate"
113
+ * @type: specifies the type of the algorithm
114
+ * @mask: specifies the mask for the algorithm
115
+ * @node: specifies the NUMA node the ZIP hardware belongs to
116
+ *
117
+ * Allocate a handle for a compression algorithm. Drivers should try to use
118
+ * (de)compressors on the specified NUMA node.
119
+ * The returned struct crypto_acomp is the handle that is required for any
120
+ * subsequent API invocation for the compression operations.
121
+ *
122
+ * Return: allocated handle in case of success; IS_ERR() is true in case
123
+ * of an error, PTR_ERR() returns the error code.
124
+ */
125
+struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type,
126
+ u32 mask, int node);
114127
115128 static inline struct crypto_tfm *crypto_acomp_tfm(struct crypto_acomp *tfm)
116129 {
....@@ -164,7 +177,7 @@
164177 {
165178 type &= ~CRYPTO_ALG_TYPE_MASK;
166179 type |= CRYPTO_ALG_TYPE_ACOMPRESS;
167
- mask |= CRYPTO_ALG_TYPE_MASK;
180
+ mask |= CRYPTO_ALG_TYPE_ACOMPRESS_MASK;
168181
169182 return crypto_has_alg(alg_name, type, mask);
170183 }
....@@ -248,8 +261,14 @@
248261 static inline int crypto_acomp_compress(struct acomp_req *req)
249262 {
250263 struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);
264
+ struct crypto_alg *alg = tfm->base.__crt_alg;
265
+ unsigned int slen = req->slen;
266
+ int ret;
251267
252
- return tfm->compress(req);
268
+ crypto_stats_get(alg);
269
+ ret = tfm->compress(req);
270
+ crypto_stats_compress(slen, ret, alg);
271
+ return ret;
253272 }
254273
255274 /**
....@@ -264,8 +283,14 @@
264283 static inline int crypto_acomp_decompress(struct acomp_req *req)
265284 {
266285 struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);
286
+ struct crypto_alg *alg = tfm->base.__crt_alg;
287
+ unsigned int slen = req->slen;
288
+ int ret;
267289
268
- return tfm->decompress(req);
290
+ crypto_stats_get(alg);
291
+ ret = tfm->decompress(req);
292
+ crypto_stats_decompress(slen, ret, alg);
293
+ return ret;
269294 }
270295
271296 #endif