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

crypto: ixp4xx - check firmware for crypto support

- the loaded firmware may not support crypto at all or
only support DES and 3DES but not AES or
support DES, 3DES and AES.

- in case of no crypto support of the firmware, the module load will fail.
- in case of missing AES support, the AES algorithms are not registered
and a warning is printed during module load.

Signed-off-by: Christian Hohnstaedt <chohnstaedt@innominate.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Christian Hohnstaedt and committed by
Herbert Xu
295c01f9 0d44dc59

+32 -1
+32 -1
drivers/crypto/ixp4xx_crypto.c
··· 415 415 static int init_ixp_crypto(void) 416 416 { 417 417 int ret = -ENODEV; 418 + u32 msg[2] = { 0, 0 }; 418 419 419 420 if (! ( ~(*IXP4XX_EXP_CFG2) & (IXP4XX_FEATURE_HASH | 420 421 IXP4XX_FEATURE_AES | IXP4XX_FEATURE_DES))) { ··· 427 426 return ret; 428 427 429 428 if (!npe_running(npe_c)) { 430 - npe_load_firmware(npe_c, npe_name(npe_c), dev); 429 + ret = npe_load_firmware(npe_c, npe_name(npe_c), dev); 430 + if (ret) { 431 + return ret; 432 + } 433 + if (npe_recv_message(npe_c, msg, "STATUS_MSG")) 434 + goto npe_error; 435 + } else { 436 + if (npe_send_message(npe_c, msg, "STATUS_MSG")) 437 + goto npe_error; 438 + 439 + if (npe_recv_message(npe_c, msg, "STATUS_MSG")) 440 + goto npe_error; 431 441 } 432 442 443 + switch ((msg[1]>>16) & 0xff) { 444 + case 3: 445 + printk(KERN_WARNING "Firmware of %s lacks AES support\n", 446 + npe_name(npe_c)); 447 + support_aes = 0; 448 + break; 449 + case 4: 450 + case 5: 451 + support_aes = 1; 452 + break; 453 + default: 454 + printk(KERN_ERR "Firmware of %s lacks crypto support\n", 455 + npe_name(npe_c)); 456 + return -ENODEV; 457 + } 433 458 /* buffer_pool will also be used to sometimes store the hmac, 434 459 * so assure it is large enough 435 460 */ ··· 486 459 487 460 qmgr_enable_irq(RECV_QID); 488 461 return 0; 462 + 463 + npe_error: 464 + printk(KERN_ERR "%s not responding\n", npe_name(npe_c)); 465 + ret = -EIO; 489 466 err: 490 467 if (ctx_pool) 491 468 dma_pool_destroy(ctx_pool);