@@ -87,7 +87,7 @@ struct caam_ctx {
87
87
u32 class2_alg_type ;
88
88
u32 alg_op ;
89
89
u8 * key ;
90
- dma_addr_t key_phys ;
90
+ dma_addr_t key_dma ;
91
91
unsigned int enckeylen ;
92
92
unsigned int split_key_len ;
93
93
unsigned int split_key_pad_len ;
@@ -263,9 +263,9 @@ static int build_sh_desc_ipsec(struct caam_ctx *ctx)
263
263
ctx -> split_key_pad_len , ctx -> enckeylen ,
264
264
ctx -> enckeylen , CLASS_1 | KEY_DEST_CLASS_REG );
265
265
} else {
266
- append_key (sh_desc , ctx -> key_phys , ctx -> split_key_len , CLASS_2 |
266
+ append_key (sh_desc , ctx -> key_dma , ctx -> split_key_len , CLASS_2 |
267
267
KEY_DEST_MDHA_SPLIT | KEY_ENC );
268
- append_key (sh_desc , ctx -> key_phys + ctx -> split_key_pad_len ,
268
+ append_key (sh_desc , ctx -> key_dma + ctx -> split_key_pad_len ,
269
269
ctx -> enckeylen , CLASS_1 | KEY_DEST_CLASS_REG );
270
270
}
271
271
@@ -342,9 +342,9 @@ static int aead_setkey(struct crypto_aead *aead,
342
342
/* postpend encryption key to auth split key */
343
343
memcpy (ctx -> key + ctx -> split_key_pad_len , key + authkeylen , enckeylen );
344
344
345
- ctx -> key_phys = dma_map_single (jrdev , ctx -> key , ctx -> split_key_pad_len +
345
+ ctx -> key_dma = dma_map_single (jrdev , ctx -> key , ctx -> split_key_pad_len +
346
346
enckeylen , DMA_TO_DEVICE );
347
- if (dma_mapping_error (jrdev , ctx -> key_phys )) {
347
+ if (dma_mapping_error (jrdev , ctx -> key_dma )) {
348
348
dev_err (jrdev , "unable to map key i/o memory\n" );
349
349
kfree (ctx -> key );
350
350
return - ENOMEM ;
@@ -359,7 +359,7 @@ static int aead_setkey(struct crypto_aead *aead,
359
359
360
360
ret = build_sh_desc_ipsec (ctx );
361
361
if (ret ) {
362
- dma_unmap_single (jrdev , ctx -> key_phys , ctx -> split_key_pad_len +
362
+ dma_unmap_single (jrdev , ctx -> key_dma , ctx -> split_key_pad_len +
363
363
enckeylen , DMA_TO_DEVICE );
364
364
kfree (ctx -> key );
365
365
}
@@ -884,11 +884,20 @@ static int aead_givencrypt(struct aead_givcrypt_request *areq)
884
884
return init_aead_job (edesc , req , OP_ALG_ENCRYPT , aead_encrypt_done );
885
885
}
886
886
887
+ #define template_aead template_u.aead
887
888
struct caam_alg_template {
888
889
char name [CRYPTO_MAX_ALG_NAME ];
889
890
char driver_name [CRYPTO_MAX_ALG_NAME ];
890
891
unsigned int blocksize ;
891
- struct aead_alg aead ;
892
+ u32 type ;
893
+ union {
894
+ struct ablkcipher_alg ablkcipher ;
895
+ struct aead_alg aead ;
896
+ struct blkcipher_alg blkcipher ;
897
+ struct cipher_alg cipher ;
898
+ struct compress_alg compress ;
899
+ struct rng_alg rng ;
900
+ } template_u ;
892
901
u32 class1_alg_type ;
893
902
u32 class2_alg_type ;
894
903
u32 alg_op ;
@@ -900,7 +909,8 @@ static struct caam_alg_template driver_algs[] = {
900
909
.name = "authenc(hmac(sha1),cbc(aes))" ,
901
910
.driver_name = "authenc-hmac-sha1-cbc-aes-caam" ,
902
911
.blocksize = AES_BLOCK_SIZE ,
903
- .aead = {
912
+ .type = CRYPTO_ALG_TYPE_AEAD ,
913
+ .template_aead = {
904
914
.setkey = aead_setkey ,
905
915
.setauthsize = aead_setauthsize ,
906
916
.encrypt = aead_encrypt ,
@@ -918,7 +928,8 @@ static struct caam_alg_template driver_algs[] = {
918
928
.name = "authenc(hmac(sha256),cbc(aes))" ,
919
929
.driver_name = "authenc-hmac-sha256-cbc-aes-caam" ,
920
930
.blocksize = AES_BLOCK_SIZE ,
921
- .aead = {
931
+ .type = CRYPTO_ALG_TYPE_AEAD ,
932
+ .template_aead = {
922
933
.setkey = aead_setkey ,
923
934
.setauthsize = aead_setauthsize ,
924
935
.encrypt = aead_encrypt ,
@@ -937,7 +948,8 @@ static struct caam_alg_template driver_algs[] = {
937
948
.name = "authenc(hmac(sha512),cbc(aes))" ,
938
949
.driver_name = "authenc-hmac-sha512-cbc-aes-caam" ,
939
950
.blocksize = AES_BLOCK_SIZE ,
940
- .aead = {
951
+ .type = CRYPTO_ALG_TYPE_AEAD ,
952
+ .template_aead = {
941
953
.setkey = aead_setkey ,
942
954
.setauthsize = aead_setauthsize ,
943
955
.encrypt = aead_encrypt ,
@@ -956,7 +968,8 @@ static struct caam_alg_template driver_algs[] = {
956
968
.name = "authenc(hmac(sha1),cbc(des3_ede))" ,
957
969
.driver_name = "authenc-hmac-sha1-cbc-des3_ede-caam" ,
958
970
.blocksize = DES3_EDE_BLOCK_SIZE ,
959
- .aead = {
971
+ .type = CRYPTO_ALG_TYPE_AEAD ,
972
+ .template_aead = {
960
973
.setkey = aead_setkey ,
961
974
.setauthsize = aead_setauthsize ,
962
975
.encrypt = aead_encrypt ,
@@ -974,7 +987,8 @@ static struct caam_alg_template driver_algs[] = {
974
987
.name = "authenc(hmac(sha256),cbc(des3_ede))" ,
975
988
.driver_name = "authenc-hmac-sha256-cbc-des3_ede-caam" ,
976
989
.blocksize = DES3_EDE_BLOCK_SIZE ,
977
- .aead = {
990
+ .type = CRYPTO_ALG_TYPE_AEAD ,
991
+ .template_aead = {
978
992
.setkey = aead_setkey ,
979
993
.setauthsize = aead_setauthsize ,
980
994
.encrypt = aead_encrypt ,
@@ -993,7 +1007,8 @@ static struct caam_alg_template driver_algs[] = {
993
1007
.name = "authenc(hmac(sha512),cbc(des3_ede))" ,
994
1008
.driver_name = "authenc-hmac-sha512-cbc-des3_ede-caam" ,
995
1009
.blocksize = DES3_EDE_BLOCK_SIZE ,
996
- .aead = {
1010
+ .type = CRYPTO_ALG_TYPE_AEAD ,
1011
+ .template_aead = {
997
1012
.setkey = aead_setkey ,
998
1013
.setauthsize = aead_setauthsize ,
999
1014
.encrypt = aead_encrypt ,
@@ -1012,7 +1027,8 @@ static struct caam_alg_template driver_algs[] = {
1012
1027
.name = "authenc(hmac(sha1),cbc(des))" ,
1013
1028
.driver_name = "authenc-hmac-sha1-cbc-des-caam" ,
1014
1029
.blocksize = DES_BLOCK_SIZE ,
1015
- .aead = {
1030
+ .type = CRYPTO_ALG_TYPE_AEAD ,
1031
+ .template_aead = {
1016
1032
.setkey = aead_setkey ,
1017
1033
.setauthsize = aead_setauthsize ,
1018
1034
.encrypt = aead_encrypt ,
@@ -1030,7 +1046,8 @@ static struct caam_alg_template driver_algs[] = {
1030
1046
.name = "authenc(hmac(sha256),cbc(des))" ,
1031
1047
.driver_name = "authenc-hmac-sha256-cbc-des-caam" ,
1032
1048
.blocksize = DES_BLOCK_SIZE ,
1033
- .aead = {
1049
+ .type = CRYPTO_ALG_TYPE_AEAD ,
1050
+ .template_aead = {
1034
1051
.setkey = aead_setkey ,
1035
1052
.setauthsize = aead_setauthsize ,
1036
1053
.encrypt = aead_encrypt ,
@@ -1049,7 +1066,8 @@ static struct caam_alg_template driver_algs[] = {
1049
1066
.name = "authenc(hmac(sha512),cbc(des))" ,
1050
1067
.driver_name = "authenc-hmac-sha512-cbc-des-caam" ,
1051
1068
.blocksize = DES_BLOCK_SIZE ,
1052
- .aead = {
1069
+ .type = CRYPTO_ALG_TYPE_AEAD ,
1070
+ .template_aead = {
1053
1071
.setkey = aead_setkey ,
1054
1072
.setauthsize = aead_setauthsize ,
1055
1073
.encrypt = aead_encrypt ,
@@ -1107,8 +1125,8 @@ static void caam_cra_exit(struct crypto_tfm *tfm)
1107
1125
desc_bytes (ctx -> sh_desc ), DMA_TO_DEVICE );
1108
1126
kfree (ctx -> sh_desc );
1109
1127
1110
- if (!dma_mapping_error (ctx -> jrdev , ctx -> key_phys ))
1111
- dma_unmap_single (ctx -> jrdev , ctx -> key_phys ,
1128
+ if (!dma_mapping_error (ctx -> jrdev , ctx -> key_dma ))
1129
+ dma_unmap_single (ctx -> jrdev , ctx -> key_dma ,
1112
1130
ctx -> split_key_pad_len + ctx -> enckeylen ,
1113
1131
DMA_TO_DEVICE );
1114
1132
kfree (ctx -> key );
@@ -1175,12 +1193,16 @@ static struct caam_crypto_alg *caam_alg_alloc(struct device *ctrldev,
1175
1193
alg -> cra_init = caam_cra_init ;
1176
1194
alg -> cra_exit = caam_cra_exit ;
1177
1195
alg -> cra_priority = CAAM_CRA_PRIORITY ;
1178
- alg -> cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC ;
1179
1196
alg -> cra_blocksize = template -> blocksize ;
1180
1197
alg -> cra_alignmask = 0 ;
1181
- alg -> cra_type = & crypto_aead_type ;
1182
1198
alg -> cra_ctxsize = sizeof (struct caam_ctx );
1183
- alg -> cra_u .aead = template -> aead ;
1199
+ alg -> cra_flags = CRYPTO_ALG_ASYNC | template -> type ;
1200
+ switch (template -> type ) {
1201
+ case CRYPTO_ALG_TYPE_AEAD :
1202
+ alg -> cra_type = & crypto_aead_type ;
1203
+ alg -> cra_aead = template -> template_aead ;
1204
+ break ;
1205
+ }
1184
1206
1185
1207
t_alg -> class1_alg_type = template -> class1_alg_type ;
1186
1208
t_alg -> class2_alg_type = template -> class2_alg_type ;
0 commit comments