9
9
#include <crypto/gcm.h>
10
10
#include <crypto/internal/aead.h>
11
11
#include <crypto/scatterwalk.h>
12
-
13
12
#include <linux/dma-mapping.h>
13
+ #include <linux/err.h>
14
+ #include <linux/firmware/xlnx-zynqmp.h>
15
+ #include <linux/kernel.h>
14
16
#include <linux/module.h>
15
17
#include <linux/of_device.h>
16
18
#include <linux/platform_device.h>
17
-
18
- #include <linux/firmware/xlnx-zynqmp.h>
19
+ #include <linux/string.h>
19
20
20
21
#define ZYNQMP_DMA_BIT_MASK 32U
21
22
@@ -43,7 +44,7 @@ enum zynqmp_aead_keysrc {
43
44
44
45
struct zynqmp_aead_drv_ctx {
45
46
union {
46
- struct aead_alg aead ;
47
+ struct aead_engine_alg aead ;
47
48
} alg ;
48
49
struct device * dev ;
49
50
struct crypto_engine * engine ;
@@ -60,7 +61,6 @@ struct zynqmp_aead_hw_req {
60
61
};
61
62
62
63
struct zynqmp_aead_tfm_ctx {
63
- struct crypto_engine_ctx engine_ctx ;
64
64
struct device * dev ;
65
65
u8 key [ZYNQMP_AES_KEY_SIZE ];
66
66
u8 * iv ;
@@ -286,7 +286,7 @@ static int zynqmp_aes_aead_encrypt(struct aead_request *req)
286
286
struct zynqmp_aead_req_ctx * rq_ctx = aead_request_ctx (req );
287
287
288
288
rq_ctx -> op = ZYNQMP_AES_ENCRYPT ;
289
- drv_ctx = container_of (alg , struct zynqmp_aead_drv_ctx , alg .aead );
289
+ drv_ctx = container_of (alg , struct zynqmp_aead_drv_ctx , alg .aead . base );
290
290
291
291
return crypto_transfer_aead_request_to_engine (drv_ctx -> engine , req );
292
292
}
@@ -299,7 +299,7 @@ static int zynqmp_aes_aead_decrypt(struct aead_request *req)
299
299
struct zynqmp_aead_req_ctx * rq_ctx = aead_request_ctx (req );
300
300
301
301
rq_ctx -> op = ZYNQMP_AES_DECRYPT ;
302
- drv_ctx = container_of (alg , struct zynqmp_aead_drv_ctx , alg .aead );
302
+ drv_ctx = container_of (alg , struct zynqmp_aead_drv_ctx , alg .aead . base );
303
303
304
304
return crypto_transfer_aead_request_to_engine (drv_ctx -> engine , req );
305
305
}
@@ -312,18 +312,16 @@ static int zynqmp_aes_aead_init(struct crypto_aead *aead)
312
312
struct zynqmp_aead_drv_ctx * drv_ctx ;
313
313
struct aead_alg * alg = crypto_aead_alg (aead );
314
314
315
- drv_ctx = container_of (alg , struct zynqmp_aead_drv_ctx , alg .aead );
315
+ drv_ctx = container_of (alg , struct zynqmp_aead_drv_ctx , alg .aead . base );
316
316
tfm_ctx -> dev = drv_ctx -> dev ;
317
317
318
- tfm_ctx -> engine_ctx .op .do_one_request = zynqmp_handle_aes_req ;
319
-
320
- tfm_ctx -> fbk_cipher = crypto_alloc_aead (drv_ctx -> alg .aead .base .cra_name ,
318
+ tfm_ctx -> fbk_cipher = crypto_alloc_aead (drv_ctx -> alg .aead .base .base .cra_name ,
321
319
0 ,
322
320
CRYPTO_ALG_NEED_FALLBACK );
323
321
324
322
if (IS_ERR (tfm_ctx -> fbk_cipher )) {
325
323
pr_err ("%s() Error: failed to allocate fallback for %s\n" ,
326
- __func__ , drv_ctx -> alg .aead .base .cra_name );
324
+ __func__ , drv_ctx -> alg .aead .base .base . cra_name );
327
325
return PTR_ERR (tfm_ctx -> fbk_cipher );
328
326
}
329
327
@@ -348,7 +346,7 @@ static void zynqmp_aes_aead_exit(struct crypto_aead *aead)
348
346
}
349
347
350
348
static struct zynqmp_aead_drv_ctx aes_drv_ctx = {
351
- .alg .aead = {
349
+ .alg .aead . base = {
352
350
.setkey = zynqmp_aes_aead_setkey ,
353
351
.setauthsize = zynqmp_aes_aead_setauthsize ,
354
352
.encrypt = zynqmp_aes_aead_encrypt ,
@@ -370,7 +368,10 @@ static struct zynqmp_aead_drv_ctx aes_drv_ctx = {
370
368
.cra_ctxsize = sizeof (struct zynqmp_aead_tfm_ctx ),
371
369
.cra_module = THIS_MODULE ,
372
370
}
373
- }
371
+ },
372
+ .alg .aead .op = {
373
+ .do_one_request = zynqmp_handle_aes_req ,
374
+ },
374
375
};
375
376
376
377
static int zynqmp_aes_aead_probe (struct platform_device * pdev )
@@ -403,15 +404,15 @@ static int zynqmp_aes_aead_probe(struct platform_device *pdev)
403
404
goto err_engine ;
404
405
}
405
406
406
- err = crypto_register_aead (& aes_drv_ctx .alg .aead );
407
+ err = crypto_engine_register_aead (& aes_drv_ctx .alg .aead );
407
408
if (err < 0 ) {
408
409
dev_err (dev , "Failed to register AEAD alg.\n" );
409
410
goto err_aead ;
410
411
}
411
412
return 0 ;
412
413
413
414
err_aead :
414
- crypto_unregister_aead (& aes_drv_ctx .alg .aead );
415
+ crypto_engine_unregister_aead (& aes_drv_ctx .alg .aead );
415
416
416
417
err_engine :
417
418
if (aes_drv_ctx .engine )
@@ -423,7 +424,7 @@ static int zynqmp_aes_aead_probe(struct platform_device *pdev)
423
424
static int zynqmp_aes_aead_remove (struct platform_device * pdev )
424
425
{
425
426
crypto_engine_exit (aes_drv_ctx .engine );
426
- crypto_unregister_aead (& aes_drv_ctx .alg .aead );
427
+ crypto_engine_unregister_aead (& aes_drv_ctx .alg .aead );
427
428
428
429
return 0 ;
429
430
}
0 commit comments