[dpdk-dev,1/4] bus/dpaa: scan for DPAA Crypto devices
Checks
Commit Message
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
config/defconfig_arm64-dpaa-linuxapp-gcc | 3 ++
drivers/bus/dpaa/dpaa_bus.c | 51 ++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
Comments
> -----Original Message-----
> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]
> Sent: Thursday, August 24, 2017 1:01 AM
> To: dev@dpdk.org; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Cc: Doherty, Declan <declan.doherty@intel.com>; Mcnamara, John
> <john.mcnamara@intel.com>; hemant.agrawal@nxp.com; Akhil Goyal
> <akhil.goyal@nxp.com>
> Subject: [PATCH 1/4] bus/dpaa: scan for DPAA Crypto devices
>
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> ---
> config/defconfig_arm64-dpaa-linuxapp-gcc | 3 ++
> drivers/bus/dpaa/dpaa_bus.c | 51
> ++++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
>
> diff --git a/config/defconfig_arm64-dpaa-linuxapp-gcc
> b/config/defconfig_arm64-dpaa-linuxapp-gcc
> index c0f5e4a..7c8cf3c 100644
> --- a/config/defconfig_arm64-dpaa-linuxapp-gcc
> +++ b/config/defconfig_arm64-dpaa-linuxapp-gcc
> @@ -62,3 +62,6 @@
> CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="dpaa"
> # Compile software NXP DPAA PMD
> CONFIG_RTE_LIBRTE_DPAA_PMD=y
> CONFIG_RTE_LIBRTE_DPAA_PMD_DEBUG=n
> +
> +# 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 7ae5bfa..18c8d97 100644
> --- a/drivers/bus/dpaa/dpaa_bus.c
> +++ b/drivers/bus/dpaa/dpaa_bus.c
> @@ -93,6 +93,21 @@ dpaa_remove_from_device_list(struct
> rte_dpaa_device *dev)
> TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next); }
>
> +/* Reads the SEC device and ERA from DTS by using the of library
Missing a word between "the" and "of"?
> + * 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 +149,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 (QI interfaces), for number of
> + * device, that can be created.
> + */
I would reword the last sentence, probably removing the commas and changing "device" for "devices".
@@ -62,3 +62,6 @@ CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="dpaa"
# Compile software NXP DPAA PMD
CONFIG_RTE_LIBRTE_DPAA_PMD=y
CONFIG_RTE_LIBRTE_DPAA_PMD_DEBUG=n
+
+# DPAA CAAM driver instances
+CONFIG_RTE_LIBRTE_DPAA_MAX_CRYPTODEV=4
@@ -93,6 +93,21 @@ dpaa_remove_from_device_list(struct rte_dpaa_device *dev)
TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next);
}
+/* Reads the SEC device and ERA from DTS by using the of library
+ * 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 +149,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 (QI interfaces), for number of
+ * device, 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: