Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Synchronous Compression operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2015 LG Electronics Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c) 2016, Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef _CRYPTO_SCOMP_INT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define _CRYPTO_SCOMP_INT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/crypto.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define SCOMP_SCRATCH_SIZE	131072
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct crypto_scomp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	struct crypto_tfm base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * struct scomp_alg - synchronous compression algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * @alloc_ctx:	Function allocates algorithm specific context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * @free_ctx:	Function frees context allocated with alloc_ctx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * @compress:	Function performs a compress operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * @decompress:	Function performs a de-compress operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * @base:	Common crypto API algorithm data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct scomp_alg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	void *(*alloc_ctx)(struct crypto_scomp *tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	void (*free_ctx)(struct crypto_scomp *tfm, void *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	int (*compress)(struct crypto_scomp *tfm, const u8 *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			unsigned int slen, u8 *dst, unsigned int *dlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 			void *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int (*decompress)(struct crypto_scomp *tfm, const u8 *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 			  unsigned int slen, u8 *dst, unsigned int *dlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			  void *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct crypto_alg base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static inline struct scomp_alg *__crypto_scomp_alg(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	return container_of(alg, struct scomp_alg, base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static inline struct crypto_scomp *__crypto_scomp_tfm(struct crypto_tfm *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	return container_of(tfm, struct crypto_scomp, base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static inline struct crypto_tfm *crypto_scomp_tfm(struct crypto_scomp *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return &tfm->base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static inline void crypto_free_scomp(struct crypto_scomp *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	crypto_destroy_tfm(tfm, crypto_scomp_tfm(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static inline struct scomp_alg *crypto_scomp_alg(struct crypto_scomp *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	return __crypto_scomp_alg(crypto_scomp_tfm(tfm)->__crt_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static inline void *crypto_scomp_alloc_ctx(struct crypto_scomp *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	return crypto_scomp_alg(tfm)->alloc_ctx(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static inline void crypto_scomp_free_ctx(struct crypto_scomp *tfm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 					 void *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	return crypto_scomp_alg(tfm)->free_ctx(tfm, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static inline int crypto_scomp_compress(struct crypto_scomp *tfm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 					const u8 *src, unsigned int slen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 					u8 *dst, unsigned int *dlen, void *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	return crypto_scomp_alg(tfm)->compress(tfm, src, slen, dst, dlen, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 					  const u8 *src, unsigned int slen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 					  u8 *dst, unsigned int *dlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 					  void *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	return crypto_scomp_alg(tfm)->decompress(tfm, src, slen, dst, dlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 						 ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) int crypto_init_scomp_ops_async(struct crypto_tfm *tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) struct acomp_req *crypto_acomp_scomp_alloc_ctx(struct acomp_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) void crypto_acomp_scomp_free_ctx(struct acomp_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * crypto_register_scomp() -- Register synchronous compression algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * Function registers an implementation of a synchronous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * compression algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * @alg:	algorithm definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * Return: zero on success; error code in case of error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int crypto_register_scomp(struct scomp_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * crypto_unregister_scomp() -- Unregister synchronous compression algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * Function unregisters an implementation of a synchronous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * compression algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * @alg:	algorithm definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) void crypto_unregister_scomp(struct scomp_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int crypto_register_scomps(struct scomp_alg *algs, int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) void crypto_unregister_scomps(struct scomp_alg *algs, int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #endif