linux-brain/drivers/crypto/caam/intern.h

309 lines
7.0 KiB
C
Raw Normal View History

License cleanup: add SPDX GPL-2.0 license identifier to files with no license Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 23:07:57 +09:00
/* SPDX-License-Identifier: GPL-2.0 */
/*
* CAAM/SEC 4.x driver backend
* Private/internal definitions between modules
*
* Copyright 2008-2011 Freescale Semiconductor, Inc.
* Copyright 2019 NXP
*/
#ifndef INTERN_H
#define INTERN_H
#include "ctrl.h"
#include <crypto/engine.h>
/* Currently comes from Kconfig param as a ^2 (driver-required) */
#define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
/* Kconfig params for interrupt coalescing if selected (else zero) */
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
#define JOBR_INTC JRCFG_ICEN
#define JOBR_INTC_TIME_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD
#define JOBR_INTC_COUNT_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_COUNT_THLD
#else
#define JOBR_INTC 0
#define JOBR_INTC_TIME_THLD 0
#define JOBR_INTC_COUNT_THLD 0
#endif
/*
* Storage for tracking each in-process entry moving across a ring
* Each entry on an output ring needs one of these
*/
struct caam_jrentry_info {
void (*callbk)(struct device *dev, u32 *desc, u32 status, void *arg);
void *cbkarg; /* Argument per ring entry */
u32 *desc_addr_virt; /* Stored virt addr for postprocessing */
dma_addr_t desc_addr_dma; /* Stored bus addr for done matching */
u32 desc_size; /* Stored size for postprocessing, header derived */
};
#ifdef CONFIG_PM_SLEEP
struct caam_jr_state {
dma_addr_t inpbusaddr;
dma_addr_t outbusaddr;
};
#endif
struct caam_jr_dequeue_params {
struct device *dev;
int enable_itr;
};
/* Private sub-storage for a single JobR */
struct caam_drv_private_jr {
struct list_head list_node; /* Job Ring device list */
struct device *dev;
int ridx;
struct caam_job_ring __iomem *rregs; /* JobR's register space */
2016-11-09 17:46:21 +09:00
struct tasklet_struct irqtask;
struct caam_jr_dequeue_params tasklet_params;
int irq; /* One per queue */
/* Number of scatterlist crypt transforms active on the JobR */
atomic_t tfm_count ____cacheline_aligned;
/* Job ring info */
struct caam_jrentry_info *entinfo; /* Alloc'ed 1 per ring entry */
spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */
u32 inpring_avail; /* Number of free entries in input ring */
int head; /* entinfo (s/w ring) head index */
void *inpring; /* Base of input ring, alloc
* DMA-safe */
int out_ring_read_index; /* Output index "tail" */
int tail; /* entinfo (s/w ring) tail index */
void *outring; /* Base of output ring, DMA-safe */
struct crypto_engine *engine;
#ifdef CONFIG_PM_SLEEP
struct caam_jr_state state; /* State of the JR during PM */
#endif
};
#ifdef CONFIG_PM_SLEEP
struct caam_ctl_state {
struct masterid deco_mid[16];
struct masterid jr_mid[4];
u32 mcr;
u32 scfgr;
};
#endif
/*
* Driver-private storage for a single CAAM block instance
*/
struct caam_drv_private {
MLKU-25-3 crypto: caam - add Secure Memory support This is a squash of the following i.MX BSP commits (rel_imx_4.19.35_1.1.0_rc2) 1. ae8175a3f1be ("MLK-9710-10 Add CCM defs for FIFO_STORE instruction") 2. 9512280d066b ("MLK-9769-11 Add SM register defs, and expanded driver-private storage.") 3. a9dc44de8150 ("MLK-9769-10 Add Blob command bitdefs.") 4. 8f6a17b41917 ("ENGR00289885 [iMX6Q] Add Secure Memory and SECVIO support.") 5. c7d4f9db1077 ("MLK-9710-11 Add internal key cover and external blob export/import to prototype SM-API") 6. 568e449edfca ("MLK-9710-12 Adapt sm_test as a black-key handling example") 7. f42f12d9cb19 ("MLK-9710-13 Correct size in BLOB_OVERHEAD definition") 8. 022fc2b33f57 ("MLK-9710-14 Un-pad cache sizes for blob export/import") 9. 8d3e8c3c4dc1 ("MLK-9710-15 Correct size of padded key buffers") 10. 997fb2ff88ec ("MLK-9710-5 Unregister Secure Memory platform device upon shutdown") 11. 5316249198ee ("MLK-10897-1 ARM: imx7d: Add CAAM support for i.mx7d") 12. 07566f42a4ec ("MLK-11103 Missing register in Secure memory configuration v1") 13. 3004636304e1 ("MLK-12302 caam: Secure Memory platform device creation crashes") 14. 0e6ed5a819f7 ("MLK-13779 crypto: caam - initialize kslock spinlock") 15. b1254b6b5f52 ("Add missing NULL checks in CAAM sm") 16. 61f57509bc9a ("MLK-17992: caam: sm: Fix compilation warnings") 17. 41cf3d4c580c ("MLK-15473-1: crypto: caam: Add CAAM driver support for iMX8 soc family") 18. bb8742481209 ("MLK-17253-1: crypto: caam: Fix computation of SM pages addresses") 19. 308796dfae3b ("MLK-17253-2: crypto: caam: Use correct memory function for Secure Memory") 20. ba2cb6b5fb10 ("MLK-17732-2: SM store: Support iMX8QX and iMX8QM") 21. de710d376af6 ("MLK-17674-1: sm_store remove CONFIG_OF") 22. cfcae647434e ("MLK-17674-2: CAAM SM : get base address from device tree") 23. f49ebbd5eefa ("MLK-17992: caam: sm: Fix compilation warnings") 24. 345ead4338b9 ("MLK-17841: crypto: caam: Correct bugs in Secure Memory") 25. c17811f3fffc ("MLK-18082: crypto: caam: sm: Fix encap/decap function to handle errors") 26. 41bcba1d4c9b ("MLK-18082: crypto: caam: sm: Fix descriptor running functions") 27. b7385ab94784 ("MLK-20204: drivers: crypto: caam: sm: Remove deadcode") 28. 1d749430cb63 ("MLK-20204: drivers: crypto: caam: sm: test: Dealloc keyslot properly") 29. 6a5c2d9d358f ("crypto: caam - lower SM test verbosity") 30. 1a6bc92c0c87 ("MLK-21617: crypto: caam - update SM test error handling") Signed-off-by: Dan Douglass <dan.douglass@nxp.com> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> Signed-off-by: Steve Cornelius <steve.cornelius@nxp.com> Signed-off-by: Octavian Purdila <octavian.purdila@nxp.com> Signed-off-by: Radu Solea <radu.solea@nxp.com> Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com> Signed-off-by: Silvano di Ninno <silvano.dininno@nxp.com> that have been reworked: 4. -make SM depend on JR -enable SM, SECVIO only on i.MX SoCs -fix resource leak - add off_node_put() where needed Split commit in three: 1 - SNVS/SECVIO driver 2 - Secure Memory driver 3 - DT changes 11. Clock handling dropped - logic already upstream. 17. Keep only Secure Memory related changes. Changes related to page 0 registers have been added previously. Other changes are dropped. 21. Always use first jr in ctrlpriv->jr[] array to access registers in page 0 (aliased in jr page), irrespective of SCU presence. Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
2013-07-24 12:47:32 +09:00
struct device *smdev;
MLKU-38-3 crypto: caam - add SNVS / SECVIO support This is a squash of the following i.MX BSP commits (rel_imx_4.19.35_1.1.0_rc2) 1. 8f6a17b41917 ("ENGR00289885 [iMX6Q] Add Secure Memory and SECVIO support.") 2. 8433c811e97a ("MLK-9710-18 snvs - make SECVIO module device tree correct") 3. 35bbc34e996b ("MLK-9769-23 Replace SECVIO of_irq_to_resource() with irq_of_parse_and_map()") 4. 3ac6edcd92d4 ("MLK-11360-01 crypto: caam_snvs: add snvs clock management") 5. 9d9ca7a03e3b ("MLK-11922 i.mx6: Linux 3.14.28 CAAM & SNVS enabled by default. JTAG, DS-5 attachment causes exceptions") 6. fcdaabf1bba2 ("MLK-17412-01: Fix secvio driver to have same driver name as DTS") Signed-off-by: Dan Douglass <dan.douglass@nxp.com> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> Signed-off-by: Steve Cornelius <steve.cornelius@nxp.com> Signed-off-by: Fugang Duan <andy.duan@nxp.com> Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> that have been reworked: 1. -make SM depend on JR -enable SM, SECVIO only on i.MX SoCs -fix resource leak - add off_node_put() where needed Split commit in three: - SNVS/SECVIO driver - Secure Memory driver - DT changes 3. JR changes dropped - no longer needed, already upstream in commit 549077d7d86a1 ("crypto: caam - check irq_of_parse_and_map for errors") 4. Split the patch in two: -DT bindings changes -driver changes 5. Fixed conflicts in imx7d.dtsi - added caam_sm and irq_sec_vio nodes. Split commit in 3: -SECVIO/SNVS driver changes -SECVIO/SNVS DT changes -Secure Memory DT changes Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
2019-09-30 06:22:09 +09:00
/* Physical-presence section */
struct caam_ctrl __iomem *ctrl; /* controller region */
struct caam_deco __iomem *deco; /* DECO/CCB views */
struct caam_assurance __iomem *assure;
struct caam_queue_if __iomem *qi; /* QI control region */
struct caam_job_ring __iomem *jr[4]; /* JobR's register space */
MLKU-25-3 crypto: caam - add Secure Memory support This is a squash of the following i.MX BSP commits (rel_imx_4.19.35_1.1.0_rc2) 1. ae8175a3f1be ("MLK-9710-10 Add CCM defs for FIFO_STORE instruction") 2. 9512280d066b ("MLK-9769-11 Add SM register defs, and expanded driver-private storage.") 3. a9dc44de8150 ("MLK-9769-10 Add Blob command bitdefs.") 4. 8f6a17b41917 ("ENGR00289885 [iMX6Q] Add Secure Memory and SECVIO support.") 5. c7d4f9db1077 ("MLK-9710-11 Add internal key cover and external blob export/import to prototype SM-API") 6. 568e449edfca ("MLK-9710-12 Adapt sm_test as a black-key handling example") 7. f42f12d9cb19 ("MLK-9710-13 Correct size in BLOB_OVERHEAD definition") 8. 022fc2b33f57 ("MLK-9710-14 Un-pad cache sizes for blob export/import") 9. 8d3e8c3c4dc1 ("MLK-9710-15 Correct size of padded key buffers") 10. 997fb2ff88ec ("MLK-9710-5 Unregister Secure Memory platform device upon shutdown") 11. 5316249198ee ("MLK-10897-1 ARM: imx7d: Add CAAM support for i.mx7d") 12. 07566f42a4ec ("MLK-11103 Missing register in Secure memory configuration v1") 13. 3004636304e1 ("MLK-12302 caam: Secure Memory platform device creation crashes") 14. 0e6ed5a819f7 ("MLK-13779 crypto: caam - initialize kslock spinlock") 15. b1254b6b5f52 ("Add missing NULL checks in CAAM sm") 16. 61f57509bc9a ("MLK-17992: caam: sm: Fix compilation warnings") 17. 41cf3d4c580c ("MLK-15473-1: crypto: caam: Add CAAM driver support for iMX8 soc family") 18. bb8742481209 ("MLK-17253-1: crypto: caam: Fix computation of SM pages addresses") 19. 308796dfae3b ("MLK-17253-2: crypto: caam: Use correct memory function for Secure Memory") 20. ba2cb6b5fb10 ("MLK-17732-2: SM store: Support iMX8QX and iMX8QM") 21. de710d376af6 ("MLK-17674-1: sm_store remove CONFIG_OF") 22. cfcae647434e ("MLK-17674-2: CAAM SM : get base address from device tree") 23. f49ebbd5eefa ("MLK-17992: caam: sm: Fix compilation warnings") 24. 345ead4338b9 ("MLK-17841: crypto: caam: Correct bugs in Secure Memory") 25. c17811f3fffc ("MLK-18082: crypto: caam: sm: Fix encap/decap function to handle errors") 26. 41bcba1d4c9b ("MLK-18082: crypto: caam: sm: Fix descriptor running functions") 27. b7385ab94784 ("MLK-20204: drivers: crypto: caam: sm: Remove deadcode") 28. 1d749430cb63 ("MLK-20204: drivers: crypto: caam: sm: test: Dealloc keyslot properly") 29. 6a5c2d9d358f ("crypto: caam - lower SM test verbosity") 30. 1a6bc92c0c87 ("MLK-21617: crypto: caam - update SM test error handling") Signed-off-by: Dan Douglass <dan.douglass@nxp.com> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> Signed-off-by: Steve Cornelius <steve.cornelius@nxp.com> Signed-off-by: Octavian Purdila <octavian.purdila@nxp.com> Signed-off-by: Radu Solea <radu.solea@nxp.com> Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com> Signed-off-by: Silvano di Ninno <silvano.dininno@nxp.com> that have been reworked: 4. -make SM depend on JR -enable SM, SECVIO only on i.MX SoCs -fix resource leak - add off_node_put() where needed Split commit in three: 1 - SNVS/SECVIO driver 2 - Secure Memory driver 3 - DT changes 11. Clock handling dropped - logic already upstream. 17. Keep only Secure Memory related changes. Changes related to page 0 registers have been added previously. Other changes are dropped. 21. Always use first jr in ctrlpriv->jr[] array to access registers in page 0 (aliased in jr page), irrespective of SCU presence. Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
2013-07-24 12:47:32 +09:00
dma_addr_t __iomem *sm_base; /* Secure memory storage base */
phys_addr_t sm_phy; /* Secure memory storage physical */
u32 sm_size;
struct iommu_domain *domain;
/*
* Detected geometry block. Filled in from device tree if powerpc,
* or from register-based version detection code
*/
u8 total_jobrs; /* Total Job Rings in device */
u8 qi_present; /* Nonzero if QI present in device */
u8 sm_present; /* Nonzero if Secure Memory is supported */
u8 mc_en; /* Nonzero if MC f/w is active */
u8 scu_en; /* Nonzero if SCU f/w is active */
MLKU-38-3 crypto: caam - add SNVS / SECVIO support This is a squash of the following i.MX BSP commits (rel_imx_4.19.35_1.1.0_rc2) 1. 8f6a17b41917 ("ENGR00289885 [iMX6Q] Add Secure Memory and SECVIO support.") 2. 8433c811e97a ("MLK-9710-18 snvs - make SECVIO module device tree correct") 3. 35bbc34e996b ("MLK-9769-23 Replace SECVIO of_irq_to_resource() with irq_of_parse_and_map()") 4. 3ac6edcd92d4 ("MLK-11360-01 crypto: caam_snvs: add snvs clock management") 5. 9d9ca7a03e3b ("MLK-11922 i.mx6: Linux 3.14.28 CAAM & SNVS enabled by default. JTAG, DS-5 attachment causes exceptions") 6. fcdaabf1bba2 ("MLK-17412-01: Fix secvio driver to have same driver name as DTS") Signed-off-by: Dan Douglass <dan.douglass@nxp.com> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> Signed-off-by: Steve Cornelius <steve.cornelius@nxp.com> Signed-off-by: Fugang Duan <andy.duan@nxp.com> Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> that have been reworked: 1. -make SM depend on JR -enable SM, SECVIO only on i.MX SoCs -fix resource leak - add off_node_put() where needed Split commit in three: - SNVS/SECVIO driver - Secure Memory driver - DT changes 3. JR changes dropped - no longer needed, already upstream in commit 549077d7d86a1 ("crypto: caam - check irq_of_parse_and_map for errors") 4. Split the patch in two: -DT bindings changes -driver changes 5. Fixed conflicts in imx7d.dtsi - added caam_sm and irq_sec_vio nodes. Split commit in 3: -SECVIO/SNVS driver changes -SECVIO/SNVS DT changes -Secure Memory DT changes Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
2019-09-30 06:22:09 +09:00
u8 optee_en; /* Nonzero if OP-TEE f/w is active */
int virt_en; /* Virtualization enabled in CAAM */
int era; /* CAAM Era (internal HW revision) */
#define RNG4_MAX_HANDLES 2
/* RNG4 block */
u32 rng4_sh_init; /* This bitmap shows which of the State
Handles of the RNG4 block are initialized
by this driver */
struct clk_bulk_data *clks;
int num_clks;
/*
* debugfs entries for developer view into driver/device
* variables at runtime.
*/
#ifdef CONFIG_DEBUG_FS
struct dentry *ctl; /* controller dir */
struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap;
#endif
#ifdef CONFIG_PM_SLEEP
int caam_off_during_pm; /* If the CAAM is reset after suspend */
struct caam_ctl_state state; /* State of the CTL during PM */
#endif
};
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API
int caam_algapi_init(struct device *dev);
void caam_algapi_exit(void);
#else
static inline int caam_algapi_init(struct device *dev)
{
return 0;
}
static inline void caam_algapi_exit(void)
{
}
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API */
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API
int caam_algapi_hash_init(struct device *dev);
void caam_algapi_hash_exit(void);
#else
static inline int caam_algapi_hash_init(struct device *dev)
{
return 0;
}
static inline void caam_algapi_hash_exit(void)
{
}
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API */
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_PKC_API
int caam_pkc_init(struct device *dev);
void caam_pkc_exit(void);
#else
static inline int caam_pkc_init(struct device *dev)
{
return 0;
}
static inline void caam_pkc_exit(void)
{
}
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_PKC_API */
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API
int caam_rng_init(struct device *dev);
void caam_rng_exit(void);
#else
static inline int caam_rng_init(struct device *dev)
{
return 0;
}
static inline void caam_rng_exit(void)
{
}
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API */
#ifdef CONFIG_CAAM_QI
int caam_qi_algapi_init(struct device *dev);
void caam_qi_algapi_exit(void);
#else
static inline int caam_qi_algapi_init(struct device *dev)
{
return 0;
}
static inline void caam_qi_algapi_exit(void)
{
}
#endif /* CONFIG_CAAM_QI */
crypto: caam - add Queue Interface (QI) backend support CAAM engine supports two interfaces for crypto job submission: -job ring interface - already existing caam/jr driver -Queue Interface (QI) - caam/qi driver added in current patch QI is present in CAAM engines found on DPAA platforms. QI gets its I/O (frame descriptors) from QMan (Queue Manager) queues. This patch adds a platform device for accessing CAAM's queue interface. The requests are submitted to CAAM using one frame queue per cryptographic context. Each crypto context has one shared descriptor. This shared descriptor is attached to frame queue associated with corresponding driver context using context_a. The driver hides the mechanics of FQ creation, initialisation from its applications. Each cryptographic context needs to be associated with driver context which houses the FQ to be used to transport the job to CAAM. The driver provides API for: (a) Context creation (b) Job submission (c) Context deletion (d) Congestion indication - whether path to/from CAAM is congested The driver supports affining its context to a particular CPU. This means that any responses from CAAM for the context in question would arrive at the given CPU. This helps in implementing one CPU per packet round trip in IPsec application. The driver processes CAAM responses under NAPI contexts. NAPI contexts are instantiated only on cores with affined portals since only cores having their own portal can receive responses from DQRR. The responses from CAAM for all cryptographic contexts ride on a fixed set of FQs. We use one response FQ per portal owning core. The response FQ is configured in each core's and thus portal's dedicated channel. This gives the flexibility to direct CAAM's responses for a crypto context on a given core. Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-03-17 19:06:01 +09:00
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_SM
int caam_sm_startup(struct device *dev);
void caam_sm_shutdown(struct device *dev);
#else
static inline int caam_sm_startup(struct device *dev)
{
return 0;
}
static inline void caam_sm_shutdown(struct device *dev)
{
}
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_SM */
#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_TK_API
int caam_keygen_init(void);
void caam_keygen_exit(void);
#else
static inline int caam_keygen_init(void)
{
return 0;
}
static inline void caam_keygen_exit(void)
{
}
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_TK_API */
crypto: caam - add Queue Interface (QI) backend support CAAM engine supports two interfaces for crypto job submission: -job ring interface - already existing caam/jr driver -Queue Interface (QI) - caam/qi driver added in current patch QI is present in CAAM engines found on DPAA platforms. QI gets its I/O (frame descriptors) from QMan (Queue Manager) queues. This patch adds a platform device for accessing CAAM's queue interface. The requests are submitted to CAAM using one frame queue per cryptographic context. Each crypto context has one shared descriptor. This shared descriptor is attached to frame queue associated with corresponding driver context using context_a. The driver hides the mechanics of FQ creation, initialisation from its applications. Each cryptographic context needs to be associated with driver context which houses the FQ to be used to transport the job to CAAM. The driver provides API for: (a) Context creation (b) Job submission (c) Context deletion (d) Congestion indication - whether path to/from CAAM is congested The driver supports affining its context to a particular CPU. This means that any responses from CAAM for the context in question would arrive at the given CPU. This helps in implementing one CPU per packet round trip in IPsec application. The driver processes CAAM responses under NAPI contexts. NAPI contexts are instantiated only on cores with affined portals since only cores having their own portal can receive responses from DQRR. The responses from CAAM for all cryptographic contexts ride on a fixed set of FQs. We use one response FQ per portal owning core. The response FQ is configured in each core's and thus portal's dedicated channel. This gives the flexibility to direct CAAM's responses for a crypto context on a given core. Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-03-17 19:06:01 +09:00
#ifdef CONFIG_DEBUG_FS
static int caam_debugfs_u64_get(void *data, u64 *val)
{
*val = caam64_to_cpu(*(u64 *)data);
return 0;
}
static int caam_debugfs_u32_get(void *data, u64 *val)
{
*val = caam32_to_cpu(*(u32 *)data);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n");
DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n");
#endif
static inline u64 caam_get_dma_mask(struct device *dev)
{
struct device_node *nprop = dev->of_node;
if (caam_ptr_sz != sizeof(u64))
return DMA_BIT_MASK(32);
if (caam_dpaa2)
return DMA_BIT_MASK(49);
if (of_device_is_compatible(nprop, "fsl,sec-v5.0-job-ring") ||
of_device_is_compatible(nprop, "fsl,sec-v5.0"))
return DMA_BIT_MASK(40);
return DMA_BIT_MASK(36);
}
#endif /* INTERN_H */