Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 313ea293 authored by Ruchika Gupta's avatar Ruchika Gupta Committed by Herbert Xu
Browse files

crypto: caam - Add Platform driver for Job Ring



The SEC Job Rings are now available as individual devices.
This would enable sharing of job rings between kernel and
user space. Job Rings can now be dynamically bound/unbound
from kernel.

Changes are made in the following layers of CAAM Driver
1. Controller driver
        - Does basic initialization of CAAM Block.
        - Creates platform devices for Job Rings.
(Earlier the initialization of Job ring  was done
 by the controller driver)

2. JobRing Platform driver
        - Manages the platform Job Ring devices created
          by the controller driver

Signed-off-by: default avatarRuchika Gupta <ruchika.gupta@freescale.com>
Reviewed-by: default avatarGarg Vakul-B16394 <vakul@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0d289788
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -4,16 +4,29 @@ config CRYPTO_DEV_FSL_CAAM
	help
	  Enables the driver module for Freescale's Cryptographic Accelerator
	  and Assurance Module (CAAM), also known as the SEC version 4 (SEC4).
	  This module adds a job ring operation interface, and configures h/w
	  This module creates job ring devices, and configures h/w
	  to operate as a DPAA component automatically, depending
	  on h/w feature availability.

	  To compile this driver as a module, choose M here: the module
	  will be called caam.

config CRYPTO_DEV_FSL_CAAM_JR
	tristate "Freescale CAAM Job Ring driver backend"
	depends on CRYPTO_DEV_FSL_CAAM
	default y
	help
	  Enables the driver module for Job Rings which are part of
	  Freescale's Cryptographic Accelerator
	  and Assurance Module (CAAM). This module adds a job ring operation
	  interface.

	  To compile this driver as a module, choose M here: the module
	  will be called caam_jr.

config CRYPTO_DEV_FSL_CAAM_RINGSIZE
	int "Job Ring size"
	depends on CRYPTO_DEV_FSL_CAAM
	depends on CRYPTO_DEV_FSL_CAAM_JR
	range 2 9
	default "9"
	help
@@ -31,7 +44,7 @@ config CRYPTO_DEV_FSL_CAAM_RINGSIZE

config CRYPTO_DEV_FSL_CAAM_INTC
	bool "Job Ring interrupt coalescing"
	depends on CRYPTO_DEV_FSL_CAAM
	depends on CRYPTO_DEV_FSL_CAAM_JR
	default n
	help
	  Enable the Job Ring's interrupt coalescing feature.
@@ -62,7 +75,7 @@ config CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD

config CRYPTO_DEV_FSL_CAAM_CRYPTO_API
	tristate "Register algorithm implementations with the Crypto API"
	depends on CRYPTO_DEV_FSL_CAAM
	depends on CRYPTO_DEV_FSL_CAAM && CRYPTO_DEV_FSL_CAAM_JR
	default y
	select CRYPTO_ALGAPI
	select CRYPTO_AUTHENC
@@ -76,7 +89,7 @@ config CRYPTO_DEV_FSL_CAAM_CRYPTO_API

config CRYPTO_DEV_FSL_CAAM_AHASH_API
	tristate "Register hash algorithm implementations with Crypto API"
	depends on CRYPTO_DEV_FSL_CAAM
	depends on CRYPTO_DEV_FSL_CAAM && CRYPTO_DEV_FSL_CAAM_JR
	default y
	select CRYPTO_HASH
	help
@@ -88,7 +101,7 @@ config CRYPTO_DEV_FSL_CAAM_AHASH_API

config CRYPTO_DEV_FSL_CAAM_RNG_API
	tristate "Register caam device for hwrng API"
	depends on CRYPTO_DEV_FSL_CAAM
	depends on CRYPTO_DEV_FSL_CAAM && CRYPTO_DEV_FSL_CAAM_JR
	default y
	select CRYPTO_RNG
	select HW_RANDOM
+3 −1
Original line number Diff line number Diff line
@@ -6,8 +6,10 @@ ifeq ($(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG), y)
endif

obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM) += caam.o
obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_JR) += caam_jr.o
obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API) += caamalg.o
obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API) += caamhash.o
obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API) += caamrng.o

caam-objs := ctrl.o jr.o error.o key_gen.o
caam-objs := ctrl.o
caam_jr-objs := jr.o key_gen.o error.o
+3 −1
Original line number Diff line number Diff line
@@ -2071,13 +2071,15 @@ static int caam_cra_init(struct crypto_tfm *tfm)
		 container_of(alg, struct caam_crypto_alg, crypto_alg);
	struct caam_ctx *ctx = crypto_tfm_ctx(tfm);
	struct caam_drv_private *priv = dev_get_drvdata(caam_alg->ctrldev);
	struct platform_device *pdev;
	int tgt_jr = atomic_inc_return(&priv->tfm_count);

	/*
	 * distribute tfms across job rings to ensure in-order
	 * crypto request processing per tfm
	 */
	ctx->jrdev = priv->jrdev[(tgt_jr / 2) % priv->total_jobrs];
	pdev = priv->jrpdev[(tgt_jr / 2) % priv->total_jobrs];
	ctx->jrdev = &pdev->dev;

	/* copy descriptor header template value */
	ctx->class1_alg_type = OP_TYPE_CLASS1_ALG | caam_alg->class1_alg_type;
+3 −1
Original line number Diff line number Diff line
@@ -1680,12 +1680,14 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
					 HASH_MSG_LEN + SHA512_DIGEST_SIZE };
	int tgt_jr = atomic_inc_return(&priv->tfm_count);
	int ret = 0;
	struct platform_device *pdev;

	/*
	 * distribute tfms across job rings to ensure in-order
	 * crypto request processing per tfm
	 */
	ctx->jrdev = priv->jrdev[tgt_jr % priv->total_jobrs];
	pdev = priv->jrpdev[tgt_jr % priv->total_jobrs];
	ctx->jrdev = &pdev->dev;

	/* copy descriptor header template value */
	ctx->alg_type = OP_TYPE_CLASS2_ALG | caam_hash->alg_type;
+4 −3
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ static void __exit caam_rng_exit(void)
static int __init caam_rng_init(void)
{
	struct device_node *dev_node;
	struct platform_device *pdev;
	struct platform_device *pdev, *jrpdev;
	struct device *ctrldev;
	struct caam_drv_private *priv;

@@ -305,9 +305,10 @@ static int __init caam_rng_init(void)
	if (!priv)
		return -ENODEV;

	caam_init_rng(&rng_ctx, priv->jrdev[0]);
	jrpdev = priv->jrpdev[0];
	caam_init_rng(&rng_ctx, &jrpdev->dev);

	dev_info(priv->jrdev[0], "registering rng-caam\n");
	dev_info(&jrpdev->dev, "registering rng-caam\n");
	return hwrng_register(&caam_rng);
}

Loading