Commit 9dbe3072 authored by Horia Geantă's avatar Horia Geantă Committed by Herbert Xu

crypto: caam/qi - ablkcipher -> skcipher conversion

Convert driver from deprecated ablkcipher API to skcipher.

Link: https://www.mail-archive.com/search?l=mid&q=20170728085622.GC19664@gondor.apana.org.auSigned-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 5ca7badb
...@@ -693,15 +693,15 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, ...@@ -693,15 +693,15 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
/* skcipher_encrypt shared descriptor */ /* skcipher_encrypt shared descriptor */
desc = ctx->sh_desc_enc; desc = ctx->sh_desc_enc;
cnstr_shdsc_ablkcipher_encap(desc, &ctx->cdata, ivsize, is_rfc3686, cnstr_shdsc_skcipher_encap(desc, &ctx->cdata, ivsize, is_rfc3686,
ctx1_iv_off); ctx1_iv_off);
dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma, dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
desc_bytes(desc), ctx->dir); desc_bytes(desc), ctx->dir);
/* skcipher_decrypt shared descriptor */ /* skcipher_decrypt shared descriptor */
desc = ctx->sh_desc_dec; desc = ctx->sh_desc_dec;
cnstr_shdsc_ablkcipher_decap(desc, &ctx->cdata, ivsize, is_rfc3686, cnstr_shdsc_skcipher_decap(desc, &ctx->cdata, ivsize, is_rfc3686,
ctx1_iv_off); ctx1_iv_off);
dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma, dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
desc_bytes(desc), ctx->dir); desc_bytes(desc), ctx->dir);
...@@ -727,13 +727,13 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, ...@@ -727,13 +727,13 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
/* xts_skcipher_encrypt shared descriptor */ /* xts_skcipher_encrypt shared descriptor */
desc = ctx->sh_desc_enc; desc = ctx->sh_desc_enc;
cnstr_shdsc_xts_ablkcipher_encap(desc, &ctx->cdata); cnstr_shdsc_xts_skcipher_encap(desc, &ctx->cdata);
dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma, dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
desc_bytes(desc), ctx->dir); desc_bytes(desc), ctx->dir);
/* xts_skcipher_decrypt shared descriptor */ /* xts_skcipher_decrypt shared descriptor */
desc = ctx->sh_desc_dec; desc = ctx->sh_desc_dec;
cnstr_shdsc_xts_ablkcipher_decap(desc, &ctx->cdata); cnstr_shdsc_xts_skcipher_decap(desc, &ctx->cdata);
dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma, dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
desc_bytes(desc), ctx->dir); desc_bytes(desc), ctx->dir);
......
/* /*
* Shared descriptors for aead, ablkcipher algorithms * Shared descriptors for aead, skcipher algorithms
* *
* Copyright 2016 NXP * Copyright 2016-2018 NXP
*/ */
#include "compat.h" #include "compat.h"
...@@ -1212,11 +1212,8 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata, ...@@ -1212,11 +1212,8 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
} }
EXPORT_SYMBOL(cnstr_shdsc_rfc4543_decap); EXPORT_SYMBOL(cnstr_shdsc_rfc4543_decap);
/* /* For skcipher encrypt and decrypt, read from req->src and write to req->dst */
* For ablkcipher encrypt and decrypt, read from req->src and static inline void skcipher_append_src_dst(u32 *desc)
* write to req->dst
*/
static inline void ablkcipher_append_src_dst(u32 *desc)
{ {
append_math_add(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ); append_math_add(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
append_math_add(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ); append_math_add(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
...@@ -1226,7 +1223,7 @@ static inline void ablkcipher_append_src_dst(u32 *desc) ...@@ -1226,7 +1223,7 @@ static inline void ablkcipher_append_src_dst(u32 *desc)
} }
/** /**
* cnstr_shdsc_ablkcipher_encap - ablkcipher encapsulation shared descriptor * cnstr_shdsc_skcipher_encap - skcipher encapsulation shared descriptor
* @desc: pointer to buffer used for descriptor construction * @desc: pointer to buffer used for descriptor construction
* @cdata: pointer to block cipher transform definitions * @cdata: pointer to block cipher transform definitions
* Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed * Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed
...@@ -1235,9 +1232,9 @@ static inline void ablkcipher_append_src_dst(u32 *desc) ...@@ -1235,9 +1232,9 @@ static inline void ablkcipher_append_src_dst(u32 *desc)
* @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template * @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template
* @ctx1_iv_off: IV offset in CONTEXT1 register * @ctx1_iv_off: IV offset in CONTEXT1 register
*/ */
void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata, void cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata,
unsigned int ivsize, const bool is_rfc3686, unsigned int ivsize, const bool is_rfc3686,
const u32 ctx1_iv_off) const u32 ctx1_iv_off)
{ {
u32 *key_jump_cmd; u32 *key_jump_cmd;
...@@ -1280,18 +1277,18 @@ void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata, ...@@ -1280,18 +1277,18 @@ void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata,
OP_ALG_ENCRYPT); OP_ALG_ENCRYPT);
/* Perform operation */ /* Perform operation */
ablkcipher_append_src_dst(desc); skcipher_append_src_dst(desc);
#ifdef DEBUG #ifdef DEBUG
print_hex_dump(KERN_ERR, print_hex_dump(KERN_ERR,
"ablkcipher enc shdesc@" __stringify(__LINE__)": ", "skcipher enc shdesc@" __stringify(__LINE__)": ",
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1); DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
#endif #endif
} }
EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_encap); EXPORT_SYMBOL(cnstr_shdsc_skcipher_encap);
/** /**
* cnstr_shdsc_ablkcipher_decap - ablkcipher decapsulation shared descriptor * cnstr_shdsc_skcipher_decap - skcipher decapsulation shared descriptor
* @desc: pointer to buffer used for descriptor construction * @desc: pointer to buffer used for descriptor construction
* @cdata: pointer to block cipher transform definitions * @cdata: pointer to block cipher transform definitions
* Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed * Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed
...@@ -1300,9 +1297,9 @@ EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_encap); ...@@ -1300,9 +1297,9 @@ EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_encap);
* @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template * @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template
* @ctx1_iv_off: IV offset in CONTEXT1 register * @ctx1_iv_off: IV offset in CONTEXT1 register
*/ */
void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata, void cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata,
unsigned int ivsize, const bool is_rfc3686, unsigned int ivsize, const bool is_rfc3686,
const u32 ctx1_iv_off) const u32 ctx1_iv_off)
{ {
u32 *key_jump_cmd; u32 *key_jump_cmd;
...@@ -1348,24 +1345,23 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata, ...@@ -1348,24 +1345,23 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
append_dec_op1(desc, cdata->algtype); append_dec_op1(desc, cdata->algtype);
/* Perform operation */ /* Perform operation */
ablkcipher_append_src_dst(desc); skcipher_append_src_dst(desc);
#ifdef DEBUG #ifdef DEBUG
print_hex_dump(KERN_ERR, print_hex_dump(KERN_ERR,
"ablkcipher dec shdesc@" __stringify(__LINE__)": ", "skcipher dec shdesc@" __stringify(__LINE__)": ",
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1); DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
#endif #endif
} }
EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_decap); EXPORT_SYMBOL(cnstr_shdsc_skcipher_decap);
/** /**
* cnstr_shdsc_xts_ablkcipher_encap - xts ablkcipher encapsulation shared * cnstr_shdsc_xts_skcipher_encap - xts skcipher encapsulation shared descriptor
* descriptor
* @desc: pointer to buffer used for descriptor construction * @desc: pointer to buffer used for descriptor construction
* @cdata: pointer to block cipher transform definitions * @cdata: pointer to block cipher transform definitions
* Valid algorithm values - OP_ALG_ALGSEL_AES ANDed with OP_ALG_AAI_XTS. * Valid algorithm values - OP_ALG_ALGSEL_AES ANDed with OP_ALG_AAI_XTS.
*/ */
void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata) void cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata)
{ {
__be64 sector_size = cpu_to_be64(512); __be64 sector_size = cpu_to_be64(512);
u32 *key_jump_cmd; u32 *key_jump_cmd;
...@@ -1400,24 +1396,23 @@ void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata) ...@@ -1400,24 +1396,23 @@ void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata)
OP_ALG_ENCRYPT); OP_ALG_ENCRYPT);
/* Perform operation */ /* Perform operation */
ablkcipher_append_src_dst(desc); skcipher_append_src_dst(desc);
#ifdef DEBUG #ifdef DEBUG
print_hex_dump(KERN_ERR, print_hex_dump(KERN_ERR,
"xts ablkcipher enc shdesc@" __stringify(__LINE__) ": ", "xts skcipher enc shdesc@" __stringify(__LINE__) ": ",
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1); DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
#endif #endif
} }
EXPORT_SYMBOL(cnstr_shdsc_xts_ablkcipher_encap); EXPORT_SYMBOL(cnstr_shdsc_xts_skcipher_encap);
/** /**
* cnstr_shdsc_xts_ablkcipher_decap - xts ablkcipher decapsulation shared * cnstr_shdsc_xts_skcipher_decap - xts skcipher decapsulation shared descriptor
* descriptor
* @desc: pointer to buffer used for descriptor construction * @desc: pointer to buffer used for descriptor construction
* @cdata: pointer to block cipher transform definitions * @cdata: pointer to block cipher transform definitions
* Valid algorithm values - OP_ALG_ALGSEL_AES ANDed with OP_ALG_AAI_XTS. * Valid algorithm values - OP_ALG_ALGSEL_AES ANDed with OP_ALG_AAI_XTS.
*/ */
void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata) void cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata)
{ {
__be64 sector_size = cpu_to_be64(512); __be64 sector_size = cpu_to_be64(512);
u32 *key_jump_cmd; u32 *key_jump_cmd;
...@@ -1451,15 +1446,15 @@ void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata) ...@@ -1451,15 +1446,15 @@ void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata)
append_dec_op1(desc, cdata->algtype); append_dec_op1(desc, cdata->algtype);
/* Perform operation */ /* Perform operation */
ablkcipher_append_src_dst(desc); skcipher_append_src_dst(desc);
#ifdef DEBUG #ifdef DEBUG
print_hex_dump(KERN_ERR, print_hex_dump(KERN_ERR,
"xts ablkcipher dec shdesc@" __stringify(__LINE__) ": ", "xts skcipher dec shdesc@" __stringify(__LINE__) ": ",
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1); DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
#endif #endif
} }
EXPORT_SYMBOL(cnstr_shdsc_xts_ablkcipher_decap); EXPORT_SYMBOL(cnstr_shdsc_xts_skcipher_decap);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("FSL CAAM descriptor support"); MODULE_DESCRIPTION("FSL CAAM descriptor support");
......
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Shared descriptors for aead, ablkcipher algorithms * Shared descriptors for aead, skcipher algorithms
* *
* Copyright 2016 NXP * Copyright 2016 NXP
*/ */
...@@ -42,10 +42,10 @@ ...@@ -42,10 +42,10 @@
#define DESC_QI_RFC4543_ENC_LEN (DESC_RFC4543_ENC_LEN + 4 * CAAM_CMD_SZ) #define DESC_QI_RFC4543_ENC_LEN (DESC_RFC4543_ENC_LEN + 4 * CAAM_CMD_SZ)
#define DESC_QI_RFC4543_DEC_LEN (DESC_RFC4543_DEC_LEN + 4 * CAAM_CMD_SZ) #define DESC_QI_RFC4543_DEC_LEN (DESC_RFC4543_DEC_LEN + 4 * CAAM_CMD_SZ)
#define DESC_ABLKCIPHER_BASE (3 * CAAM_CMD_SZ) #define DESC_SKCIPHER_BASE (3 * CAAM_CMD_SZ)
#define DESC_ABLKCIPHER_ENC_LEN (DESC_ABLKCIPHER_BASE + \ #define DESC_SKCIPHER_ENC_LEN (DESC_SKCIPHER_BASE + \
20 * CAAM_CMD_SZ) 20 * CAAM_CMD_SZ)
#define DESC_ABLKCIPHER_DEC_LEN (DESC_ABLKCIPHER_BASE + \ #define DESC_SKCIPHER_DEC_LEN (DESC_SKCIPHER_BASE + \
15 * CAAM_CMD_SZ) 15 * CAAM_CMD_SZ)
void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata, void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata,
...@@ -96,16 +96,16 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata, ...@@ -96,16 +96,16 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
unsigned int ivsize, unsigned int icvsize, unsigned int ivsize, unsigned int icvsize,
const bool is_qi); const bool is_qi);
void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata, void cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata,
unsigned int ivsize, const bool is_rfc3686, unsigned int ivsize, const bool is_rfc3686,
const u32 ctx1_iv_off); const u32 ctx1_iv_off);
void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata, void cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata,
unsigned int ivsize, const bool is_rfc3686, unsigned int ivsize, const bool is_rfc3686,
const u32 ctx1_iv_off); const u32 ctx1_iv_off);
void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata); void cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata);
void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata); void cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata);
#endif /* _CAAMALG_DESC_H_ */ #endif /* _CAAMALG_DESC_H_ */
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment