Skip to contentSkip to conversation

crypto: caam/qi2 - Add printing dpseci fq stats using debugfs

PATCH Superseded Vakul Garg 2 participants 6 messages Jul 19, 2019 – Jul 23, 2019

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Vakul Garg

author
#0 lore raw

PATCH v2 1/1 crypto: caam/qi2 - Add printing dpseci fq stats using debugfs

Add support of printing the dpseci frame queue statistics using debugfs.

---
 drivers/crypto/caam/Kconfig          | 11 +++++
 drivers/crypto/caam/Makefile         |  1 +
 drivers/crypto/caam/caamalg_qi2.c    |  5 +++
 drivers/crypto/caam/caamalg_qi2.h    |  2 +
 drivers/crypto/caam/dpseci-debugfs.c | 80 ++++++++++++++++++++++++++++++++++++
 drivers/crypto/caam/dpseci-debugfs.h | 19 +++++++++
 6 files changed, 118 insertions(+)
 create mode 100644 drivers/crypto/caam/dpseci-debugfs.c
 create mode 100644 drivers/crypto/caam/dpseci-debugfs.h
drivers/crypto/caam/Kconfig +11 -0
index 3720ddabb507..383e167e7272 100644
@@ -168,3 +168,14 @@ config CRYPTO_DEV_FSL_DPAA2_CAAM
 
 	  To compile this as a module, choose M here: the module
 	  will be called dpaa2_caam.
+
+if CRYPTO_DEV_FSL_DPAA2_CAAM
+
+config CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS
+	depends on DEBUG_FS
+	bool "Enable debugfs support"
+	help
+	  Selecting this will enable printing of various debug information
+          in the DPAA2 CAAM driver.
+
+endif
drivers/crypto/caam/Makefile +1 -0
index 9ab4e81ea21e..e4e9fa481a44 100644
@@ -30,3 +30,4 @@ endif
 obj-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM) += dpaa2_caam.o
 
 dpaa2_caam-y    := caamalg_qi2.o dpseci.o
+dpaa2_caam-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS) += dpseci-debugfs.o
drivers/crypto/caam/caamalg_qi2.c +5 -0
index 06bf32c32cbd..a78a36dfa7b9 100644
@@ -15,6 +15,7 @@
 #include "key_gen.h"
 #include "caamalg_desc.h"
 #include "caamhash_desc.h"
+#include "dpseci-debugfs.h"
 #include <linux/fsl/mc.h>
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
@@ -5098,6 +5099,8 @@ static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)
 		goto err_bind;
 	}
 
+	dpaa2_dpseci_debugfs_init(priv);
+
 	/* register crypto algorithms the device supports */
 	for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
 		struct caam_skcipher_alg *t_alg = driver_algs + i;
@@ -5265,6 +5268,8 @@ static int __cold dpaa2_caam_remove(struct fsl_mc_device *ls_dev)
 	dev = &ls_dev->dev;
 	priv = dev_get_drvdata(dev);
 
+	dpaa2_dpseci_debugfs_exit(priv);
+
 	for (i = 0; i < ARRAY_SIZE(driver_aeads); i++) {
 		struct caam_aead_alg *t_alg = driver_aeads + i;
 
drivers/crypto/caam/caamalg_qi2.h +2 -0
index 973f6296bc6f..b450e2a25c1f 100644
@@ -10,6 +10,7 @@
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
 #include <linux/threads.h>
+#include <linux/netdevice.h>
 #include "dpseci.h"
 #include "desc_constr.h"
 
@@ -64,6 +65,7 @@ struct dpaa2_caam_priv {
 	struct iommu_domain *domain;
 
 	struct dpaa2_caam_priv_per_cpu __percpu *ppriv;
+	struct dentry *dfs_root;
 };
 
 /**
drivers/crypto/caam/dpseci-debugfs.c new file +80 -0

80 lines not on this page · raw message

drivers/crypto/caam/dpseci-debugfs.h new file +19 -0
new file mode 100644
index 000000000000..9f90819a7adf
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/* Copyright 2019 NXP
+ */
+
+#ifndef DPSECI_DEBUGFS_H
+#define DPSECI_DEBUGFS_H
+
+#include <linux/dcache.h>
+#include "caamalg_qi2.h"
+
+#ifdef CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS
+void dpaa2_dpseci_debugfs_init(struct dpaa2_caam_priv *priv);
+void dpaa2_dpseci_debugfs_exit(struct dpaa2_caam_priv *priv);
+#else
+static inline void dpaa2_dpseci_debugfs_init(struct dpaa2_caam_priv *priv) {}
+static inline void dpaa2_dpseci_debugfs_exit(struct dpaa2_caam_priv *priv) {}
+#endif /* CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS */
+
+#endif /* DPSECI_DEBUGFS_H */
Signature · 1 line
2.13.6
maintainer
#1 lore raw

On 7/19/2019 2:23 PM, Vakul Garg wrote:
[...]

drivers/crypto/caam/Kconfig config CRYPTO_DEV_FSL_DPAA2_CAAM · line 181

Quoted 10 lines
drivers/crypto/caam/Kconfig +10 -0
+if CRYPTO_DEV_FSL_DPAA2_CAAM
+
+config CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS
+	depends on DEBUG_FS
+	bool "Enable debugfs support"
+	help
+	  Selecting this will enable printing of various debug information
+          in the DPAA2 CAAM driver.
+
+endif

Let's enable this based on CONFIG_DEBUG_FS.

drivers/crypto/caam/Makefile endif · line 33

Quoted 9 lines
drivers/crypto/caam/Makefile +1 -0
index 9ab4e81ea21e..e4e9fa481a44 100644
@@ -30,3 +30,4 @@ endif
 obj-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM) += dpaa2_caam.o
 
 dpaa2_caam-y    := caamalg_qi2.o dpseci.o
+dpaa2_caam-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS) += dpseci-debugfs.o

dpaa2_caam-$(CONFIG_DEBUG_FS)

[...]

drivers/crypto/caam/caamalg_qi2.h line 13

Quoted 9 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
index 973f6296bc6f..b450e2a25c1f 100644
@@ -10,6 +10,7 @@
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
 #include <linux/threads.h>
+#include <linux/netdevice.h>

How is this change related to current patch?

drivers/crypto/caam/caamalg_qi2.h struct dpaa2_caam_priv { · line 68

Quoted 8 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
 #include "dpseci.h"
 #include "desc_constr.h"
 
@@ -64,6 +65,7 @@ struct dpaa2_caam_priv {
 	struct iommu_domain *domain;
 
 	struct dpaa2_caam_priv_per_cpu __percpu *ppriv;
+	struct dentry *dfs_root;

dfs_root is used only in dpseci-debugfs.c, let's have it there as global.

Horia

author
#2 lore raw
Quoted 13 lines

-----Original Message-----
From: Horia Geanta
Sent: Monday, July 22, 2019 7:55 PM
To: Vakul Garg <[email protected]>; [email protected]
Cc: Aymen Sghaier <[email protected]>; [email protected]
Subject: Re: [PATCH v2] crypto: caam/qi2 - Add printing dpseci fq stats using debugfs

On 7/19/2019 2:23 PM, Vakul Garg wrote:
[...]

Quoted 11 lines

drivers/crypto/caam/Kconfig config CRYPTO_DEV_FSL_DPAA2_CAAM · line 181

Quoted 10 lines
drivers/crypto/caam/Kconfig +10 -0
+if CRYPTO_DEV_FSL_DPAA2_CAAM
+
+config CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS
+	depends on DEBUG_FS
+	bool "Enable debugfs support"
+	help
+	  Selecting this will enable printing of various debug information
+          in the DPAA2 CAAM driver.
+
+endif

Let's enable this based on CONFIG_DEBUG_FS.

It is not clear to me.
Do you mean not have additional CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS?

Quoted 15 lines
Quoted 3 lines
(quoted diff) +0 -0

b/drivers/crypto/caam/Makefile index 9ab4e81ea21e..e4e9fa481a44

100644

drivers/crypto/caam/Makefile endif

Quoted 8 lines
drivers/crypto/caam/Makefile +2 -0
@@ -30,3 +30,4 @@ endif
 obj-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM) += dpaa2_caam.o
 
 dpaa2_caam-y    := caamalg_qi2.o dpseci.o
+dpaa2_caam-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS) +=
+dpseci-debugfs.o

dpaa2_caam-$(CONFIG_DEBUG_FS)

[...]

Quoted 12 lines

drivers/crypto/caam/caamalg_qi2.h line 13

Quoted 10 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
index 973f6296bc6f..b450e2a25c1f 100644
@@ -10,6 +10,7 @@
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
 #include <linux/threads.h>
+#include <linux/netdevice.h>

How is this change related to current patch?

It should have been here in first place because we have some napi related things in this file. It is required as I got compilation errors now.

Quoted 11 lines

drivers/crypto/caam/caamalg_qi2.h struct dpaa2_caam_priv { · line 68

Quoted 8 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
 #include "dpseci.h"
 #include "desc_constr.h"
 
@@ -64,6 +65,7 @@ struct dpaa2_caam_priv {
 	struct iommu_domain *domain;
 
 	struct dpaa2_caam_priv_per_cpu __percpu *ppriv;
+	struct dentry *dfs_root;

dfs_root is used only in dpseci-debugfs.c, let's have it there as global.

Horia

maintainer
#3 lore raw
Quoted 23 lines · Vakul Garg
Quoted 11 lines

-----Original Message-----
From: Horia Geanta
Sent: Monday, July 22, 2019 7:55 PM
To: Vakul Garg <[email protected]>; [email protected]
Cc: Aymen Sghaier <[email protected]>; [email protected]
Subject: Re: [PATCH v2] crypto: caam/qi2 - Add printing dpseci fq stats using debugfs

On 7/19/2019 2:23 PM, Vakul Garg wrote:
[...]

Quoted 11 lines

drivers/crypto/caam/Kconfig config CRYPTO_DEV_FSL_DPAA2_CAAM · line 181

Quoted 10 lines
drivers/crypto/caam/Kconfig +10 -0
+if CRYPTO_DEV_FSL_DPAA2_CAAM
+
+config CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS
+	depends on DEBUG_FS
+	bool "Enable debugfs support"
+	help
+	  Selecting this will enable printing of various debug information
+          in the DPAA2 CAAM driver.
+
+endif

Let's enable this based on CONFIG_DEBUG_FS.

Quoted 3 lines

It is not clear to me.
Do you mean not have additional CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS?

Yes.

Quoted 28 lines
Quoted 15 lines
Quoted 3 lines
(quoted diff) +0 -0

b/drivers/crypto/caam/Makefile index 9ab4e81ea21e..e4e9fa481a44

100644

drivers/crypto/caam/Makefile endif

Quoted 8 lines
drivers/crypto/caam/Makefile +2 -0
@@ -30,3 +30,4 @@ endif
 obj-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM) += dpaa2_caam.o
 
 dpaa2_caam-y    := caamalg_qi2.o dpseci.o
+dpaa2_caam-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS) +=
+dpseci-debugfs.o

dpaa2_caam-$(CONFIG_DEBUG_FS)

[...]

Quoted 12 lines

drivers/crypto/caam/caamalg_qi2.h line 13

Quoted 10 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
index 973f6296bc6f..b450e2a25c1f 100644
@@ -10,6 +10,7 @@
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
 #include <linux/threads.h>
+#include <linux/netdevice.h>

How is this change related to current patch?

Quoted 3 lines

It should have been here in first place because we have some napi related things in this file. It is required as I got compilation errors now.

Indeed, this is caused by including caamalg_qi2.h -> dpseci-debugfs.h -> dpseci-debugfs.c.

Compiling this patch without the inclusion:

CC drivers/crypto/caam/dpseci-debugfs.o
In file included from drivers/crypto/caam/dpseci-debugfs.h:9:0,
from drivers/crypto/caam/dpseci-debugfs.c:8:
drivers/crypto/caam/caamalg_qi2.h:84:21: error: field 'napi' has incomplete type

  struct napi_struct napi;
                     ^
drivers/crypto/caam/caamalg_qi2.h:85:20: error: field 'net_dev' has incomplete type
  struct net_device net_dev;
                    ^

scripts/Makefile.build:278: recipe for target 'drivers/crypto/caam/dpseci-debugfs.o' failed

Other driver files include linux/netdevice.h indirectly, via compat.h -> linux/rtnetlink.h.

Most *.c files in drivers/crypto/caam solve dependencies by including compat.h, but this approach is messy.

Let's keep the explicit inclusion then.

Horia

author
#4 lore raw
In reply to Horia Geanta
Quoted 54 lines

-----Original Message-----
From: Horia Geanta
Sent: Monday, July 22, 2019 7:55 PM
To: Vakul Garg <[email protected]>; [email protected]
Cc: Aymen Sghaier <[email protected]>; [email protected]
Subject: Re: [PATCH v2] crypto: caam/qi2 - Add printing dpseci fq stats using debugfs

On 7/19/2019 2:23 PM, Vakul Garg wrote:
[...]

drivers/crypto/caam/Kconfig config CRYPTO_DEV_FSL_DPAA2_CAAM · line 181

Quoted 10 lines
drivers/crypto/caam/Kconfig +10 -0
+if CRYPTO_DEV_FSL_DPAA2_CAAM
+
+config CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS
+	depends on DEBUG_FS
+	bool "Enable debugfs support"
+	help
+	  Selecting this will enable printing of various debug information
+          in the DPAA2 CAAM driver.
+
+endif

Let's enable this based on CONFIG_DEBUG_FS.

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/crypto/caam/Makefile index 9ab4e81ea21e..e4e9fa481a44

100644

drivers/crypto/caam/Makefile endif

Quoted 8 lines
drivers/crypto/caam/Makefile +2 -0
@@ -30,3 +30,4 @@ endif
 obj-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM) += dpaa2_caam.o
 
 dpaa2_caam-y    := caamalg_qi2.o dpseci.o
+dpaa2_caam-$(CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM_DEBUGFS) +=
+dpseci-debugfs.o

dpaa2_caam-$(CONFIG_DEBUG_FS)

[...]

drivers/crypto/caam/caamalg_qi2.h line 13

Quoted 10 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
index 973f6296bc6f..b450e2a25c1f 100644
@@ -10,6 +10,7 @@
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
 #include <linux/threads.h>
+#include <linux/netdevice.h>

How is this change related to current patch?

Quoted 3 lines
drivers/crypto/caam/caamalg_qi2.h +0 -0
 #include "dpseci.h"
 #include "desc_constr.h"
 
Quoted 7 lines

drivers/crypto/caam/caamalg_qi2.h struct dpaa2_caam_priv { · line 68

Quoted 5 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
@@ -64,6 +65,7 @@ struct dpaa2_caam_priv {
 	struct iommu_domain *domain;
 
 	struct dpaa2_caam_priv_per_cpu __percpu *ppriv;
+	struct dentry *dfs_root;

dfs_root is used only in dpseci-debugfs.c, let's have it there as global.

I submitted this change in v3. There is still a minor issue with this patch version. Before submitting the next v4, I have a question.

Could there be a situation that there are multiple dpseci objects assigned to kernel? In that case, we need to maintain dfs_root for each separately.

Quoted 1 line

Horia

maintainer
#5 lore raw
Quoted 8 lines · Vakul Garg
Quoted 7 lines

drivers/crypto/caam/caamalg_qi2.h struct dpaa2_caam_priv { · line 68

Quoted 5 lines
drivers/crypto/caam/caamalg_qi2.h +1 -0
@@ -64,6 +65,7 @@ struct dpaa2_caam_priv {
 	struct iommu_domain *domain;
 
 	struct dpaa2_caam_priv_per_cpu __percpu *ppriv;
+	struct dentry *dfs_root;

dfs_root is used only in dpseci-debugfs.c, let's have it there as global.

Quoted 4 lines

I submitted this change in v3. There is still a minor issue with this patch version. Before submitting the next v4, I have a question.

Could there be a situation that there are multiple dpseci objects assigned to kernel?

In theory, yes.
fsl-mc, the bus dpseci devices sit on, allows for multiple instances.

However, caam/qi2 (driver for dpseci devices) doesn't have support for this.
For e.g., all dpseci instances would try to register the algorithms using the same name & driver name - something that will trigger an error in crypto API.
This could be easily fixed, however the real issue is that there is no load balancing support - neither at crypto API level nor at driver level.

Quoted 2 lines

In that case, we need to maintain dfs_root for each separately.

Ok, let's keep dfs_root per device.
For now this has no practical value, but at least makes the work easier in case load balancing support is added at some point.

Horia