From 9e54357358bfa2e6add5b4bef57fc964c3ed714b Mon Sep 17 00:00:00 2001 From: Akhil Goyal Date: Mon, 9 Oct 2017 19:51:39 +0530 Subject: [PATCH] bus/dpaa: scan for DPAA Crypto devices Signed-off-by: Shreyansh Jain Signed-off-by: Akhil Goyal --- config/defconfig_arm64-dpaa-linuxapp-gcc | 3 ++ drivers/bus/dpaa/dpaa_bus.c | 52 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/config/defconfig_arm64-dpaa-linuxapp-gcc b/config/defconfig_arm64-dpaa-linuxapp-gcc index f59834c6f5..7887fd088e 100644 --- a/config/defconfig_arm64-dpaa-linuxapp-gcc +++ b/config/defconfig_arm64-dpaa-linuxapp-gcc @@ -57,3 +57,6 @@ CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="dpaa" # Compile software NXP DPAA PMD CONFIG_RTE_LIBRTE_DPAA_PMD=y + +# DPAA CAAM driver instances +CONFIG_RTE_LIBRTE_DPAA_MAX_CRYPTODEV=4 diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 7ae5bfae80..2c594d8149 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -93,6 +93,22 @@ dpaa_remove_from_device_list(struct rte_dpaa_device *dev) TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next); } +/* + * Reads the SEC device from DTS + * Returns -1 if SEC devices not available, 0 otherwise + */ +static inline int +dpaa_sec_available(void) +{ + const struct device_node *caam_node; + + for_each_compatible_node(caam_node, NULL, "fsl,sec-v4.0") { + return 0; + } + + return -1; +} + static void dpaa_clean_device_list(void); static int @@ -134,6 +150,42 @@ dpaa_create_device_list(void) rte_dpaa_bus.device_count = i; + /* Unlike case of ETH, RTE_LIBRTE_DPAA_MAX_CRYPTODEV SEC devices are + * constantly created only if "sec" property is found in the device + * tree. Logically there is no limit for number of devices (QI + * interfaces) that can be created. + */ + + if (dpaa_sec_available()) { + DPAA_BUS_LOG(INFO, "DPAA SEC devices are not available"); + return 0; + } + + /* Creating SEC Devices */ + for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) { + dev = calloc(1, sizeof(struct rte_dpaa_device)); + if (!dev) { + DPAA_BUS_LOG(ERR, "Failed to allocate SEC devices"); + ret = -1; + goto cleanup; + } + + dev->device_type = FSL_DPAA_CRYPTO; + dev->id.dev_id = rte_dpaa_bus.device_count + i; + + /* Even though RTE_CRYPTODEV_NAME_MAX_LEN is valid length of + * crypto PMD, using RTE_ETH_NAME_MAX_LEN as that is the size + * allocated for dev->name/ + */ + memset(dev->name, 0, RTE_ETH_NAME_MAX_LEN); + sprintf(dev->name, "dpaa-sec%d", i); + DPAA_BUS_LOG(DEBUG, "Device added: %s", dev->name); + + dpaa_add_to_device_list(dev); + } + + rte_dpaa_bus.device_count += i; + return 0; cleanup: -- 2.20.1