.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Asynchronous Compression operations |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2016, Intel Corporation |
---|
5 | 6 | * Authors: Weigang Li <weigang.li@intel.com> |
---|
6 | 7 | * 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 | | - * |
---|
13 | 8 | */ |
---|
14 | 9 | #ifndef _CRYPTO_ACOMP_H |
---|
15 | 10 | #define _CRYPTO_ACOMP_H |
---|
.. | .. |
---|
111 | 106 | */ |
---|
112 | 107 | struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type, |
---|
113 | 108 | 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); |
---|
114 | 127 | |
---|
115 | 128 | static inline struct crypto_tfm *crypto_acomp_tfm(struct crypto_acomp *tfm) |
---|
116 | 129 | { |
---|
.. | .. |
---|
164 | 177 | { |
---|
165 | 178 | type &= ~CRYPTO_ALG_TYPE_MASK; |
---|
166 | 179 | type |= CRYPTO_ALG_TYPE_ACOMPRESS; |
---|
167 | | - mask |= CRYPTO_ALG_TYPE_MASK; |
---|
| 180 | + mask |= CRYPTO_ALG_TYPE_ACOMPRESS_MASK; |
---|
168 | 181 | |
---|
169 | 182 | return crypto_has_alg(alg_name, type, mask); |
---|
170 | 183 | } |
---|
.. | .. |
---|
248 | 261 | static inline int crypto_acomp_compress(struct acomp_req *req) |
---|
249 | 262 | { |
---|
250 | 263 | 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; |
---|
251 | 267 | |
---|
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; |
---|
253 | 272 | } |
---|
254 | 273 | |
---|
255 | 274 | /** |
---|
.. | .. |
---|
264 | 283 | static inline int crypto_acomp_decompress(struct acomp_req *req) |
---|
265 | 284 | { |
---|
266 | 285 | 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; |
---|
267 | 289 | |
---|
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; |
---|
269 | 294 | } |
---|
270 | 295 | |
---|
271 | 296 | #endif |
---|