From patchwork Mon Feb 8 16:10:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cabiddu, Giovanni" X-Patchwork-Id: 8251691 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 86FF6BEEE5 for ; Mon, 8 Feb 2016 16:10:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 763E020254 for ; Mon, 8 Feb 2016 16:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2113E203C3 for ; Mon, 8 Feb 2016 16:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755616AbcBHQKO (ORCPT ); Mon, 8 Feb 2016 11:10:14 -0500 Received: from mga03.intel.com ([134.134.136.65]:36346 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755611AbcBHQKN (ORCPT ); Mon, 8 Feb 2016 11:10:13 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 08 Feb 2016 08:10:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,416,1449561600"; d="scan'208";a="649040748" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 08 Feb 2016 08:10:12 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u18GAAE5009053; Mon, 8 Feb 2016 16:10:10 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u18GAALK030973; Mon, 8 Feb 2016 16:10:10 GMT Received: (from gcabiddu@localhost) by sivswdev01.ir.intel.com with id u18GAAPX030969; Mon, 8 Feb 2016 16:10:10 GMT From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, Giovanni Cabiddu Subject: [PATCH 2/2] crypto: extended acomp api for supporting deflate algorithm parameters Date: Mon, 8 Feb 2016 16:10:03 +0000 Message-Id: <1454947803-30644-3-git-send-email-giovanni.cabiddu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1454947803-30644-1-git-send-email-giovanni.cabiddu@intel.com> References: <1454947803-30644-1-git-send-email-giovanni.cabiddu@intel.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Giovanni Cabiddu --- crypto/acompress.c | 16 +++++ include/crypto/acompress.h | 116 +++++++++++++++++++++++++++++++++++ include/crypto/internal/acompress.h | 24 +++++++ 3 files changed, 156 insertions(+), 0 deletions(-) diff --git a/crypto/acompress.c b/crypto/acompress.c index 4c54ec9..37acc9d 100644 --- a/crypto/acompress.c +++ b/crypto/acompress.c @@ -114,5 +114,21 @@ int crypto_unregister_acomp(struct acomp_alg *alg) } EXPORT_SYMBOL_GPL(crypto_unregister_acomp); +int crypto_register_acomp_deflate(struct acomp_deflate_alg *deflate_alg) +{ + struct acomp_alg *alg = &deflate_alg->base; + + return crypto_register_acomp(alg); +} +EXPORT_SYMBOL_GPL(crypto_register_acomp_deflate); + +int crypto_unregister_acomp_deflate(struct acomp_deflate_alg *deflate_alg) +{ + struct acomp_alg *alg = &deflate_alg->base; + + return crypto_unregister_acomp(alg); +} +EXPORT_SYMBOL_GPL(crypto_unregister_acomp_deflate); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Asynchronous compression type"); diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index d562665..831964d 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -78,6 +78,22 @@ struct acomp_alg { }; /** + * struct acomp_deflate_alg - asynchronous deflate compression algorithm + * + * @compress_setup: Configures the compressor + * This function configures a deflate compressor. Input parameters + * are encoded in netlink format. Allowed parameters are defined + * by the acomp_deflate_params enum. + * + * @base: Generic acomp algorithm data structure + */ +struct acomp_deflate_alg { + int (*compress_setup)(struct crypto_acomp *tfm, const void *params, + unsigned int len); + struct acomp_alg base; +}; + +/** * DOC: Asynchronous Compression API * * The Asynchronous Compression API is used with the algorithms of type @@ -260,4 +276,104 @@ static inline int crypto_acomp_decompress(struct acomp_req *req) return alg->decompress(req); } +/** + * acomp_deflate_compression_levels -- Supported list of compression levels + * + * Lower values will result in less compressibility in less time + */ +enum acomp_deflate_compression_levels { + ACOMP_DEFLATE_COMP_LEVEL_DEFAULT = (-1), + ACOMP_DEFLATE_COMP_LEVEL_NO_COMPRESSION = 0, + ACOMP_DEFLATE_COMP_LEVEL_1 = 1, + ACOMP_DEFLATE_COMP_LEVEL_2 = 2, + ACOMP_DEFLATE_COMP_LEVEL_3 = 3, + ACOMP_DEFLATE_COMP_LEVEL_4 = 4, + ACOMP_DEFLATE_COMP_LEVEL_5 = 5, + ACOMP_DEFLATE_COMP_LEVEL_6 = 6, + ACOMP_DEFLATE_COMP_LEVEL_7 = 7, + ACOMP_DEFLATE_COMP_LEVEL_8 = 8, + ACOMP_DEFLATE_COMP_LEVEL_9 = 9 +}; + +/** + * acomp_deflate_huff_types -- Supported list of Huffman Tree types + * + * Specifies the Huffman tree type for the deflate algorithm + * + * ACOMP_DEFLATE_HT_DEFAULT: default encoding + * ACOMP_DEFLATE_HT_STATIC: compressor generates blocks + * "compressed with fixed Huffman trees" as defined by RFC 1951 + * ACOMP_DEFLATE_HT_FULL_DYNAMIC: compressor generates blocks + * "compressed with dynamic Huffman codes" as defined by RFC 1951 + */ +enum acomp_deflate_huff_type { + ACOMP_DEFLATE_HT_DEFAULT, + ACOMP_DEFLATE_HT_STATIC, + ACOMP_DEFLATE_HT_FULL_DYNAMIC +}; + +/** + * acomp_deflate_format_type -- Supported format types + * + * Specifies the format output + * + * ACOMP_DEFLATE_HF_RAW: output is raw deflate as defined by RFC 1951, + * no header and no trailer + * ACOMP_DEFLATE_HF_ZLIB: output is in compliance with RFC 1950, + * i.e. the deflate stream starts and finishes with a zlib header + * and footer + * ACOMP_DEFLATE_HF_GZIP: output is in compliance with RFC 1952, + * i.e. the deflate stream starts and finishes with a gzip header + * and footer + */ +enum acomp_deflate_header_type { + ACOMP_DEFLATE_FORMAT_RAW, + ACOMP_DEFLATE_FORMAT_ZLIB, + ACOMP_DEFLATE_FORMAT_GZIP +}; + +/** + * acomp_deflate_params -- Allowed deflate parameters + * + * ACOMP_DEFLATE_COMP_LEVEL: compression level, an integer + * between -1 and 9. The allowed list of values is specified by + * acomp_deflate_compression_levels + * ACOMP_DEFLATE_HUFF_TYPE: Huffman encoding, allowed values + * are specified by acomp_deflate_huff_type + * ACOMP_DEFLATE_WINDOWS_SIZE: base two logarithm of the size of the + * history buffer. Allowed values are in the range 8..15 + * ACOMP_DEFLATE_FORMAT_TYPE: specifies the format type, allowed + * values are specified by acomp_deflate_header_type + */ +enum acomp_deflate_params { + ACOMP_DEFLATE_COMP_LEVEL = 1, + ACOMP_DEFLATE_HUFF_TYPE, + ACOMP_DEFLATE_WINDOWS_SIZE, + ACOMP_DEFLATE_FORMAT_TYPE, + __ACOMP_DEFLATE_MAX, +}; + +#define ACOMP_DEFLATE_PARAMS_MAX (__ACOMP_DEFLATE_MAX - 1) + +/** + * crypto_acomp_deflate_compress_setup() -- Invoke compressor setup + * + * Function invokes the deflate compress setup operation + * + * @tfm: ACOMPRESS tfm handle + * @params: compressor input parameters in netlink format. + * Allowed parameters are defined by acomp_deflate_params + * @len: size of the parameters + * + * Return: zero on success; error code in case of error + */ +static inline int crypto_acomp_deflate_compress_setup( + struct crypto_acomp *tfm, + const void *params, unsigned int len) +{ + struct acomp_alg *alg = crypto_acomp_alg(tfm); + struct acomp_deflate_alg *deflate_alg = + container_of(alg, struct acomp_deflate_alg, base); + return deflate_alg->compress_setup(tfm, params, len); +} #endif diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h index 2061532..8218c8f 100644 --- a/include/crypto/internal/acompress.h +++ b/include/crypto/internal/acompress.h @@ -63,4 +63,28 @@ int crypto_register_acomp(struct acomp_alg *alg); */ int crypto_unregister_acomp(struct acomp_alg *alg); +/** + * crypto_register_acomp_deflate() -- Register async deflate algorithm + * + * Function registers an implementation of an asynchronous deflate + * compression algorithm + * + * @alg: algorithm definition + * + * Return: zero on success; error code in case of error + */ +int crypto_register_acomp_deflate(struct acomp_deflate_alg *deflate_alg); + +/** + * crypto_unregister_acomp_deflate() -- Unregister async deflate algorithm + * + * Function unregisters an implementation of an asynchronous deflate + * compression algorithm + * + * @alg: algorithm definition + * + * Return: zero on success; error code in case of error + */ +int crypto_unregister_acomp_deflate(struct acomp_deflate_alg *deflate_alg); + #endif