Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: xilinx - Replace zynqmp prefix with xilinx

Replace zynqmp with xilinx to have more generic name.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Harsh Jain and committed by
Herbert Xu
56934489 43f04786

+69 -71
+69 -71
drivers/crypto/xilinx/zynqmp-aes-gcm.c
··· 19 19 #include <linux/string.h> 20 20 21 21 #define ZYNQMP_DMA_BIT_MASK 32U 22 - 23 - #define ZYNQMP_AES_KEY_SIZE AES_KEYSIZE_256 24 - #define ZYNQMP_AES_AUTH_SIZE 16U 25 - #define ZYNQMP_AES_BLK_SIZE 1U 22 + #define XILINX_AES_AUTH_SIZE 16U 23 + #define XILINX_AES_BLK_SIZE 1U 26 24 #define ZYNQMP_AES_MIN_INPUT_BLK_SIZE 4U 27 25 #define ZYNQMP_AES_WORD_LEN 4U 28 26 ··· 29 31 #define ZYNQMP_AES_PUF_NOT_PROGRAMMED 0xE300 30 32 #define XILINX_KEY_MAGIC 0x3EA0 31 33 32 - enum zynqmp_aead_op { 33 - ZYNQMP_AES_DECRYPT = 0, 34 - ZYNQMP_AES_ENCRYPT 34 + enum xilinx_aead_op { 35 + XILINX_AES_DECRYPT = 0, 36 + XILINX_AES_ENCRYPT 35 37 }; 36 38 37 39 enum zynqmp_aead_keysrc { ··· 67 69 u64 keysrc; 68 70 }; 69 71 70 - struct zynqmp_aead_tfm_ctx { 72 + struct xilinx_aead_tfm_ctx { 71 73 struct device *dev; 72 - u8 key[ZYNQMP_AES_KEY_SIZE]; 74 + u8 key[AES_KEYSIZE_256]; 73 75 u8 *iv; 74 76 u32 keylen; 75 77 u32 authsize; ··· 77 79 struct crypto_aead *fbk_cipher; 78 80 }; 79 81 80 - struct zynqmp_aead_req_ctx { 81 - enum zynqmp_aead_op op; 82 + struct xilinx_aead_req_ctx { 83 + enum xilinx_aead_op op; 82 84 }; 83 85 84 86 static struct xilinx_aead_dev *aead_dev; ··· 86 88 static int zynqmp_aes_aead_cipher(struct aead_request *req) 87 89 { 88 90 struct crypto_aead *aead = crypto_aead_reqtfm(req); 89 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 90 - struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req); 91 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 92 + struct xilinx_aead_req_ctx *rq_ctx = aead_request_ctx(req); 91 93 struct device *dev = tfm_ctx->dev; 92 94 struct zynqmp_aead_hw_req *hwreq; 93 95 dma_addr_t dma_addr_data, dma_addr_hw_req; ··· 98 100 char *kbuf; 99 101 100 102 if (tfm_ctx->keysrc == ZYNQMP_AES_KUP_KEY) 101 - dma_size = req->cryptlen + ZYNQMP_AES_KEY_SIZE 103 + dma_size = req->cryptlen + AES_KEYSIZE_256 102 104 + GCM_AES_IV_SIZE; 103 105 else 104 106 dma_size = req->cryptlen + GCM_AES_IV_SIZE; ··· 124 126 hwreq->keysrc = tfm_ctx->keysrc; 125 127 hwreq->op = rq_ctx->op; 126 128 127 - if (hwreq->op == ZYNQMP_AES_ENCRYPT) 129 + if (hwreq->op == XILINX_AES_ENCRYPT) 128 130 hwreq->size = data_size; 129 131 else 130 - hwreq->size = data_size - ZYNQMP_AES_AUTH_SIZE; 132 + hwreq->size = data_size - XILINX_AES_AUTH_SIZE; 131 133 132 134 if (hwreq->keysrc == ZYNQMP_AES_KUP_KEY) { 133 135 memcpy(kbuf + data_size + GCM_AES_IV_SIZE, 134 - tfm_ctx->key, ZYNQMP_AES_KEY_SIZE); 136 + tfm_ctx->key, AES_KEYSIZE_256); 135 137 136 138 hwreq->key = hwreq->src + data_size + GCM_AES_IV_SIZE; 137 139 } else { ··· 160 162 break; 161 163 } 162 164 } else { 163 - if (hwreq->op == ZYNQMP_AES_ENCRYPT) 165 + if (hwreq->op == XILINX_AES_ENCRYPT) 164 166 data_size = data_size + crypto_aead_authsize(aead); 165 167 else 166 - data_size = data_size - ZYNQMP_AES_AUTH_SIZE; 168 + data_size = data_size - XILINX_AES_AUTH_SIZE; 167 169 168 170 sg_copy_from_buffer(req->dst, sg_nents(req->dst), 169 171 kbuf, data_size); ··· 183 185 return ret; 184 186 } 185 187 186 - static int zynqmp_fallback_check(struct zynqmp_aead_tfm_ctx *tfm_ctx, 188 + static int zynqmp_fallback_check(struct xilinx_aead_tfm_ctx *tfm_ctx, 187 189 struct aead_request *req) 188 190 { 189 - struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req); 191 + struct xilinx_aead_req_ctx *rq_ctx = aead_request_ctx(req); 190 192 191 - if (tfm_ctx->authsize != ZYNQMP_AES_AUTH_SIZE && rq_ctx->op == ZYNQMP_AES_DECRYPT) 193 + if (tfm_ctx->authsize != XILINX_AES_AUTH_SIZE && rq_ctx->op == XILINX_AES_DECRYPT) 192 194 return 1; 193 195 194 196 if (req->assoclen != 0 || ··· 201 203 if ((req->cryptlen % ZYNQMP_AES_WORD_LEN) != 0) 202 204 return 1; 203 205 204 - if (rq_ctx->op == ZYNQMP_AES_DECRYPT && 205 - req->cryptlen <= ZYNQMP_AES_AUTH_SIZE) 206 + if (rq_ctx->op == XILINX_AES_DECRYPT && 207 + req->cryptlen <= XILINX_AES_AUTH_SIZE) 206 208 return 1; 207 209 208 210 return 0; 209 211 } 210 212 211 - static int zynqmp_handle_aes_req(struct crypto_engine *engine, void *req) 213 + static int xilinx_handle_aes_req(struct crypto_engine *engine, void *req) 212 214 { 213 215 struct aead_request *areq = 214 216 container_of(req, struct aead_request, base); ··· 226 228 unsigned int keylen) 227 229 { 228 230 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 229 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 231 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 230 232 int err; 231 233 232 - if (keylen == ZYNQMP_AES_KEY_SIZE) { 234 + if (keylen == AES_KEYSIZE_256) { 233 235 memcpy(tfm_ctx->key, key, keylen); 234 236 } 235 237 ··· 250 252 unsigned int keylen) 251 253 { 252 254 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 253 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 255 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 254 256 struct xilinx_hwkey_info hwkey; 255 257 unsigned char keysrc; 256 258 int err = -EINVAL; ··· 271 273 return err; 272 274 } 273 275 274 - static int zynqmp_aes_aead_setauthsize(struct crypto_aead *aead, 276 + static int xilinx_aes_aead_setauthsize(struct crypto_aead *aead, 275 277 unsigned int authsize) 276 278 { 277 279 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 278 - struct zynqmp_aead_tfm_ctx *tfm_ctx = 279 - (struct zynqmp_aead_tfm_ctx *)crypto_tfm_ctx(tfm); 280 + struct xilinx_aead_tfm_ctx *tfm_ctx = 281 + (struct xilinx_aead_tfm_ctx *)crypto_tfm_ctx(tfm); 280 282 281 283 tfm_ctx->authsize = authsize; 282 284 return tfm_ctx->fbk_cipher ? crypto_aead_setauthsize(tfm_ctx->fbk_cipher, authsize) : 0; ··· 286 288 { 287 289 struct aead_request *subreq = aead_request_ctx(req); 288 290 struct crypto_aead *aead = crypto_aead_reqtfm(req); 289 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 291 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 290 292 291 293 aead_request_set_tfm(subreq, tfm_ctx->fbk_cipher); 292 294 aead_request_set_callback(subreq, req->base.flags, NULL, NULL); ··· 299 301 300 302 static int zynqmp_aes_aead_encrypt(struct aead_request *req) 301 303 { 302 - struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req); 304 + struct xilinx_aead_req_ctx *rq_ctx = aead_request_ctx(req); 303 305 struct crypto_aead *aead = crypto_aead_reqtfm(req); 304 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 306 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 305 307 struct aead_alg *alg = crypto_aead_alg(aead); 306 308 struct xilinx_aead_alg *drv_ctx; 307 309 int err; ··· 311 313 tfm_ctx->keylen == sizeof(struct xilinx_hwkey_info)) 312 314 return -EINVAL; 313 315 314 - rq_ctx->op = ZYNQMP_AES_ENCRYPT; 316 + rq_ctx->op = XILINX_AES_ENCRYPT; 315 317 err = zynqmp_fallback_check(tfm_ctx, req); 316 318 if (err && tfm_ctx->keysrc != ZYNQMP_AES_KUP_KEY) 317 319 return -EOPNOTSUPP; ··· 324 326 325 327 static int zynqmp_aes_aead_decrypt(struct aead_request *req) 326 328 { 327 - struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req); 329 + struct xilinx_aead_req_ctx *rq_ctx = aead_request_ctx(req); 328 330 struct crypto_aead *aead = crypto_aead_reqtfm(req); 329 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 331 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_aead_ctx(aead); 330 332 struct aead_alg *alg = crypto_aead_alg(aead); 331 333 struct xilinx_aead_alg *drv_ctx; 332 334 int err; 333 335 334 - rq_ctx->op = ZYNQMP_AES_DECRYPT; 336 + rq_ctx->op = XILINX_AES_DECRYPT; 335 337 drv_ctx = container_of(alg, struct xilinx_aead_alg, aead.base); 336 338 if (tfm_ctx->keysrc == ZYNQMP_AES_KUP_KEY && 337 339 tfm_ctx->keylen == sizeof(struct xilinx_hwkey_info)) ··· 348 350 static int xilinx_paes_aead_init(struct crypto_aead *aead) 349 351 { 350 352 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 351 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 353 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 352 354 struct xilinx_aead_alg *drv_alg; 353 355 struct aead_alg *alg = crypto_aead_alg(aead); 354 356 ··· 357 359 tfm_ctx->keylen = 0; 358 360 359 361 tfm_ctx->fbk_cipher = NULL; 360 - crypto_aead_set_reqsize(aead, sizeof(struct zynqmp_aead_req_ctx)); 362 + crypto_aead_set_reqsize(aead, sizeof(struct xilinx_aead_req_ctx)); 361 363 362 364 return 0; 363 365 } 364 366 365 - static int zynqmp_aes_aead_init(struct crypto_aead *aead) 367 + static int xilinx_aes_aead_init(struct crypto_aead *aead) 366 368 { 367 369 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 368 - struct zynqmp_aead_tfm_ctx *tfm_ctx = 369 - (struct zynqmp_aead_tfm_ctx *)crypto_tfm_ctx(tfm); 370 + struct xilinx_aead_tfm_ctx *tfm_ctx = 371 + (struct xilinx_aead_tfm_ctx *)crypto_tfm_ctx(tfm); 370 372 struct xilinx_aead_alg *drv_ctx; 371 373 struct aead_alg *alg = crypto_aead_alg(aead); 372 374 ··· 385 387 } 386 388 387 389 crypto_aead_set_reqsize(aead, 388 - max(sizeof(struct zynqmp_aead_req_ctx), 390 + max(sizeof(struct xilinx_aead_req_ctx), 389 391 sizeof(struct aead_request) + 390 392 crypto_aead_reqsize(tfm_ctx->fbk_cipher))); 391 393 return 0; ··· 394 396 static void xilinx_paes_aead_exit(struct crypto_aead *aead) 395 397 { 396 398 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 397 - struct zynqmp_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 399 + struct xilinx_aead_tfm_ctx *tfm_ctx = crypto_tfm_ctx(tfm); 398 400 399 - memzero_explicit(tfm_ctx, sizeof(struct zynqmp_aead_tfm_ctx)); 401 + memzero_explicit(tfm_ctx, sizeof(struct xilinx_aead_tfm_ctx)); 400 402 } 401 403 402 - static void zynqmp_aes_aead_exit(struct crypto_aead *aead) 404 + static void xilinx_aes_aead_exit(struct crypto_aead *aead) 403 405 { 404 406 struct crypto_tfm *tfm = crypto_aead_tfm(aead); 405 - struct zynqmp_aead_tfm_ctx *tfm_ctx = 406 - (struct zynqmp_aead_tfm_ctx *)crypto_tfm_ctx(tfm); 407 + struct xilinx_aead_tfm_ctx *tfm_ctx = 408 + (struct xilinx_aead_tfm_ctx *)crypto_tfm_ctx(tfm); 407 409 408 410 if (tfm_ctx->fbk_cipher) { 409 411 crypto_free_aead(tfm_ctx->fbk_cipher); 410 412 tfm_ctx->fbk_cipher = NULL; 411 413 } 412 - memzero_explicit(tfm_ctx, sizeof(struct zynqmp_aead_tfm_ctx)); 414 + memzero_explicit(tfm_ctx, sizeof(struct xilinx_aead_tfm_ctx)); 413 415 } 414 416 415 417 static struct xilinx_aead_alg zynqmp_aes_algs[] = { 416 418 { 417 419 .aead.base = { 418 420 .setkey = zynqmp_aes_aead_setkey, 419 - .setauthsize = zynqmp_aes_aead_setauthsize, 421 + .setauthsize = xilinx_aes_aead_setauthsize, 420 422 .encrypt = zynqmp_aes_aead_encrypt, 421 423 .decrypt = zynqmp_aes_aead_decrypt, 422 - .init = zynqmp_aes_aead_init, 423 - .exit = zynqmp_aes_aead_exit, 424 + .init = xilinx_aes_aead_init, 425 + .exit = xilinx_aes_aead_exit, 424 426 .ivsize = GCM_AES_IV_SIZE, 425 - .maxauthsize = ZYNQMP_AES_AUTH_SIZE, 427 + .maxauthsize = XILINX_AES_AUTH_SIZE, 426 428 .base = { 427 429 .cra_name = "gcm(aes)", 428 430 .cra_driver_name = "xilinx-zynqmp-aes-gcm", ··· 432 434 CRYPTO_ALG_ALLOCATES_MEMORY | 433 435 CRYPTO_ALG_KERN_DRIVER_ONLY | 434 436 CRYPTO_ALG_NEED_FALLBACK, 435 - .cra_blocksize = ZYNQMP_AES_BLK_SIZE, 436 - .cra_ctxsize = sizeof(struct zynqmp_aead_tfm_ctx), 437 + .cra_blocksize = XILINX_AES_BLK_SIZE, 438 + .cra_ctxsize = sizeof(struct xilinx_aead_tfm_ctx), 437 439 .cra_module = THIS_MODULE, 438 440 } 439 441 }, 440 442 .aead.op = { 441 - .do_one_request = zynqmp_handle_aes_req, 443 + .do_one_request = xilinx_handle_aes_req, 442 444 }, 443 445 .dma_bit_mask = ZYNQMP_DMA_BIT_MASK, 444 446 }, 445 447 { 446 448 .aead.base = { 447 449 .setkey = zynqmp_paes_aead_setkey, 448 - .setauthsize = zynqmp_aes_aead_setauthsize, 450 + .setauthsize = xilinx_aes_aead_setauthsize, 449 451 .encrypt = zynqmp_aes_aead_encrypt, 450 452 .decrypt = zynqmp_aes_aead_decrypt, 451 453 .init = xilinx_paes_aead_init, 452 454 .exit = xilinx_paes_aead_exit, 453 455 .ivsize = GCM_AES_IV_SIZE, 454 - .maxauthsize = ZYNQMP_AES_AUTH_SIZE, 456 + .maxauthsize = XILINX_AES_AUTH_SIZE, 455 457 .base = { 456 458 .cra_name = "gcm(paes)", 457 459 .cra_driver_name = "xilinx-zynqmp-paes-gcm", ··· 460 462 CRYPTO_ALG_ASYNC | 461 463 CRYPTO_ALG_ALLOCATES_MEMORY | 462 464 CRYPTO_ALG_KERN_DRIVER_ONLY, 463 - .cra_blocksize = ZYNQMP_AES_BLK_SIZE, 464 - .cra_ctxsize = sizeof(struct zynqmp_aead_tfm_ctx), 465 + .cra_blocksize = XILINX_AES_BLK_SIZE, 466 + .cra_ctxsize = sizeof(struct xilinx_aead_tfm_ctx), 465 467 .cra_module = THIS_MODULE, 466 468 } 467 469 }, 468 470 .aead.op = { 469 - .do_one_request = zynqmp_handle_aes_req, 471 + .do_one_request = xilinx_handle_aes_req, 470 472 }, 471 473 .dma_bit_mask = ZYNQMP_DMA_BIT_MASK, 472 474 }, ··· 482 484 { /* sentinel */ } 483 485 }; 484 486 485 - static int zynqmp_aes_aead_probe(struct platform_device *pdev) 487 + static int xilinx_aes_aead_probe(struct platform_device *pdev) 486 488 { 487 489 struct xilinx_aead_alg *aead_algs; 488 490 struct device *dev = &pdev->dev; ··· 546 548 return err; 547 549 } 548 550 549 - static void zynqmp_aes_aead_remove(struct platform_device *pdev) 551 + static void xilinx_aes_aead_remove(struct platform_device *pdev) 550 552 { 551 553 aead_dev = platform_get_drvdata(pdev); 552 554 crypto_engine_exit(aead_dev->engine); ··· 556 558 aead_dev = NULL; 557 559 } 558 560 559 - static struct platform_driver zynqmp_aes_driver = { 560 - .probe = zynqmp_aes_aead_probe, 561 - .remove = zynqmp_aes_aead_remove, 561 + static struct platform_driver xilinx_aes_driver = { 562 + .probe = xilinx_aes_aead_probe, 563 + .remove = xilinx_aes_aead_remove, 562 564 .driver = { 563 565 .name = "zynqmp-aes", 564 566 }, ··· 570 572 { 571 573 int ret; 572 574 573 - ret = platform_driver_register(&zynqmp_aes_driver); 575 + ret = platform_driver_register(&xilinx_aes_driver); 574 576 if (ret) 575 577 return ret; 576 578 577 - platform_dev = platform_device_register_simple(zynqmp_aes_driver.driver.name, 579 + platform_dev = platform_device_register_simple(xilinx_aes_driver.driver.name, 578 580 0, NULL, 0); 579 581 if (IS_ERR(platform_dev)) { 580 582 ret = PTR_ERR(platform_dev); 581 - platform_driver_unregister(&zynqmp_aes_driver); 583 + platform_driver_unregister(&xilinx_aes_driver); 582 584 } 583 585 584 586 return ret; ··· 587 589 static void __exit aes_driver_exit(void) 588 590 { 589 591 platform_device_unregister(platform_dev); 590 - platform_driver_unregister(&zynqmp_aes_driver); 592 + platform_driver_unregister(&xilinx_aes_driver); 591 593 } 592 594 593 595 module_init(aes_driver_init);