All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname.
@ 2018-09-21 11:38 Srikanth Jampala
  2018-09-21 11:38 ` [PATCH cryptodev-2.6 2/3] crypto: cavium/nitrox - add support for per device request statistics Srikanth Jampala
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Srikanth Jampala @ 2018-09-21 11:38 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, sgadam, Jampala.Srikanth

Get the device partname based on it's capabilities like,
core frequency, number of cores and revision id.

Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
---
 drivers/crypto/cavium/nitrox/nitrox_csr.h  | 111 +++++++++++++++++++++
 drivers/crypto/cavium/nitrox/nitrox_dev.h  |  17 +++-
 drivers/crypto/cavium/nitrox/nitrox_hal.c  |  57 +++++++++++
 drivers/crypto/cavium/nitrox/nitrox_hal.h  |   1 +
 drivers/crypto/cavium/nitrox/nitrox_main.c |  20 ----
 5 files changed, 184 insertions(+), 22 deletions(-)

diff --git a/drivers/crypto/cavium/nitrox/nitrox_csr.h b/drivers/crypto/cavium/nitrox/nitrox_csr.h
index 9dcb7fdbe0a7..1ad27b1a87c5 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_csr.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_csr.h
@@ -7,9 +7,16 @@
 
 /* EMU clusters */
 #define NR_CLUSTERS		4
+/* Maximum cores per cluster,
+ * varies based on partname
+ */
 #define AE_CORES_PER_CLUSTER	20
 #define SE_CORES_PER_CLUSTER	16
 
+#define AE_MAX_CORES	(AE_CORES_PER_CLUSTER * NR_CLUSTERS)
+#define SE_MAX_CORES	(SE_CORES_PER_CLUSTER * NR_CLUSTERS)
+#define ZIP_MAX_CORES	5
+
 /* BIST registers */
 #define EMU_BIST_STATUSX(_i)	(0x1402700 + ((_i) * 0x40000))
 #define UCD_BIST_STATUS		0x12C0070
@@ -111,6 +118,9 @@
 #define LBC_ELM_VF65_128_INT		0x120C000
 #define LBC_ELM_VF65_128_INT_ENA_W1S	0x120F000
 
+#define RST_BOOT	0x10C1600
+#define FUS_DAT1	0x10C1408
+
 /* PEM registers */
 #define PEM0_INT 0x1080428
 
@@ -1082,4 +1092,105 @@ union lbc_inval_status {
 	} s;
 };
 
+/**
+ * struct rst_boot: RST Boot Register
+ * @jtcsrdis: when set, internal CSR access via JTAG TAP controller
+ *   is disabled
+ * @jt_tst_mode: JTAG test mode
+ * @io_supply: I/O power supply setting based on IO_VDD_SELECT pin:
+ *    0x1 = 1.8V
+ *    0x2 = 2.5V
+ *    0x4 = 3.3V
+ *    All other values are reserved
+ * @pnr_mul: clock multiplier
+ * @lboot: last boot cause mask, resets only with PLL_DC_OK
+ * @rboot: determines whether core 0 remains in reset after
+ *    chip cold or warm or soft reset
+ * @rboot_pin: read only access to REMOTE_BOOT pin
+ */
+union rst_boot {
+	u64 value;
+	struct {
+#if (defined(__BIG_ENDIAN_BITFIELD))
+		u64 raz_63 : 1;
+		u64 jtcsrdis : 1;
+		u64 raz_59_61 : 3;
+		u64 jt_tst_mode : 1;
+		u64 raz_40_57 : 18;
+		u64 io_supply : 3;
+		u64 raz_30_36 : 7;
+		u64 pnr_mul : 6;
+		u64 raz_12_23 : 12;
+		u64 lboot : 10;
+		u64 rboot : 1;
+		u64 rboot_pin : 1;
+#else
+		u64 rboot_pin : 1;
+		u64 rboot : 1;
+		u64 lboot : 10;
+		u64 raz_12_23 : 12;
+		u64 pnr_mul : 6;
+		u64 raz_30_36 : 7;
+		u64 io_supply : 3;
+		u64 raz_40_57 : 18;
+		u64 jt_tst_mode : 1;
+		u64 raz_59_61 : 3;
+		u64 jtcsrdis : 1;
+		u64 raz_63 : 1;
+#endif
+	};
+};
+
+/**
+ * struct fus_dat1: Fuse Data 1 Register
+ * @pll_mul: main clock PLL multiplier hardware limit
+ * @pll_half_dis: main clock PLL control
+ * @efus_lck: efuse lockdown
+ * @zip_info: ZIP information
+ * @bar2_sz_conf: when zero, BAR2 size conforms to
+ *    PCIe specification
+ * @efus_ign: efuse ignore
+ * @nozip: ZIP disable
+ * @pll_alt_matrix: select alternate PLL matrix
+ * @pll_bwadj_denom: select CLKF denominator for
+ *    BWADJ value
+ * @chip_id: chip ID
+ */
+union fus_dat1 {
+	u64 value;
+	struct {
+#if (defined(__BIG_ENDIAN_BITFIELD))
+		u64 raz_57_63 : 7;
+		u64 pll_mul : 3;
+		u64 pll_half_dis : 1;
+		u64 raz_43_52 : 10;
+		u64 efus_lck : 3;
+		u64 raz_26_39 : 14;
+		u64 zip_info : 5;
+		u64 bar2_sz_conf : 1;
+		u64 efus_ign : 1;
+		u64 nozip : 1;
+		u64 raz_11_17 : 7;
+		u64 pll_alt_matrix : 1;
+		u64 pll_bwadj_denom : 2;
+		u64 chip_id : 8;
+#else
+		u64 chip_id : 8;
+		u64 pll_bwadj_denom : 2;
+		u64 pll_alt_matrix : 1;
+		u64 raz_11_17 : 7;
+		u64 nozip : 1;
+		u64 efus_ign : 1;
+		u64 bar2_sz_conf : 1;
+		u64 zip_info : 5;
+		u64 raz_26_39 : 14;
+		u64 efus_lck : 3;
+		u64 raz_43_52 : 10;
+		u64 pll_half_dis : 1;
+		u64 pll_mul : 3;
+		u64 raz_57_63 : 7;
+#endif
+	};
+};
+
 #endif /* __NITROX_CSR_H */
diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
index 4f560cedd0aa..1059495ee541 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
@@ -5,6 +5,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/if.h>
 
 #define VERSION_LEN 32
 
@@ -48,15 +49,27 @@ struct nitrox_cmdq {
 	dma_addr_t dma;
 };
 
+/**
+ * struct nitrox_hw - NITROX hardware information
+ * @partname: partname ex: CNN55xxx-xxx
+ * @fw_name: firmware version
+ * @freq: NITROX frequency
+ * @vendor_id: vendor ID
+ * @device_id: device ID
+ * @revision_id: revision ID
+ * @se_cores: number of symmetric cores
+ * @ae_cores: number of asymmetric cores
+ * @zip_cores: number of zip cores
+ */
 struct nitrox_hw {
-	/* firmware version */
+	char partname[IFNAMSIZ * 2];
 	char fw_name[VERSION_LEN];
 
+	int freq;
 	u16 vendor_id;
 	u16 device_id;
 	u8 revision_id;
 
-	/* CNN55XX cores */
 	u8 se_cores;
 	u8 ae_cores;
 	u8 zip_cores;
diff --git a/drivers/crypto/cavium/nitrox/nitrox_hal.c b/drivers/crypto/cavium/nitrox/nitrox_hal.c
index 2b256ba36dff..4627a1976176 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_hal.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_hal.c
@@ -4,6 +4,8 @@
 #include "nitrox_dev.h"
 #include "nitrox_csr.h"
 
+#define PLL_REF_CLK 50
+
 /**
  * emu_enable_cores - Enable EMU cluster cores.
  * @ndev: N5 device
@@ -410,3 +412,58 @@ void config_nps_core_vfcfg_mode(struct nitrox_device *ndev, enum vf_mode mode)
 
 	nitrox_write_csr(ndev, NPS_CORE_GBL_VFCFG, vfcfg.value);
 }
+
+void nitrox_get_hwinfo(struct nitrox_device *ndev)
+{
+	union emu_fuse_map emu_fuse;
+	union rst_boot rst_boot;
+	union fus_dat1 fus_dat1;
+	unsigned char name[IFNAMSIZ * 2] = {};
+	int i, dead_cores;
+	u64 offset;
+
+	/* get core frequency */
+	offset = RST_BOOT;
+	rst_boot.value = nitrox_read_csr(ndev, offset);
+	ndev->hw.freq = (rst_boot.pnr_mul + 3) * PLL_REF_CLK;
+
+	for (i = 0; i < NR_CLUSTERS; i++) {
+		offset = EMU_FUSE_MAPX(i);
+		emu_fuse.value = nitrox_read_csr(ndev, offset);
+		if (emu_fuse.s.valid) {
+			dead_cores = hweight32(emu_fuse.s.ae_fuse);
+			ndev->hw.ae_cores += AE_CORES_PER_CLUSTER - dead_cores;
+			dead_cores = hweight16(emu_fuse.s.se_fuse);
+			ndev->hw.se_cores += SE_CORES_PER_CLUSTER - dead_cores;
+		}
+	}
+	/* find zip hardware availability */
+	offset = FUS_DAT1;
+	fus_dat1.value = nitrox_read_csr(ndev, offset);
+	if (!fus_dat1.nozip) {
+		dead_cores = hweight8(fus_dat1.zip_info);
+		ndev->hw.zip_cores = ZIP_MAX_CORES - dead_cores;
+	}
+
+	/* determine the partname CNN55<cores>-<freq><pincount>-<rev>*/
+	if (ndev->hw.ae_cores == AE_MAX_CORES) {
+		switch (ndev->hw.se_cores) {
+		case SE_MAX_CORES:
+			i = snprintf(name, sizeof(name), "CNN5560");
+			break;
+		case 40:
+			i = snprintf(name, sizeof(name), "CNN5560s");
+			break;
+		}
+	} else if (ndev->hw.ae_cores == (AE_MAX_CORES / 2)) {
+		i = snprintf(name, sizeof(name), "CNN5530");
+	} else {
+		i = snprintf(name, sizeof(name), "CNN5560i");
+	}
+
+	snprintf(name + i, sizeof(name) - i, "-%3dBG676-1.%u",
+		 ndev->hw.freq, ndev->hw.revision_id);
+
+	/* copy partname */
+	strncpy(ndev->hw.partname, name, sizeof(ndev->hw.partname));
+}
diff --git a/drivers/crypto/cavium/nitrox/nitrox_hal.h b/drivers/crypto/cavium/nitrox/nitrox_hal.h
index 3baef865b17c..489ee64c119e 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_hal.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_hal.h
@@ -18,5 +18,6 @@ void invalidate_lbc(struct nitrox_device *ndev);
 void enable_pkt_input_ring(struct nitrox_device *ndev, int ring);
 void enable_pkt_solicit_port(struct nitrox_device *ndev, int port);
 void config_nps_core_vfcfg_mode(struct nitrox_device *ndev, enum vf_mode mode);
+void nitrox_get_hwinfo(struct nitrox_device *ndev);
 
 #endif /* __NITROX_HAL_H */
diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
index 6d7a421bddb8..acce0f0b9c7a 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -291,26 +291,6 @@ static int nitrox_bist_check(struct nitrox_device *ndev)
 	return 0;
 }
 
-static void nitrox_get_hwinfo(struct nitrox_device *ndev)
-{
-	union emu_fuse_map emu_fuse;
-	u64 offset;
-	int i;
-
-	for (i = 0; i < NR_CLUSTERS; i++) {
-		u8 dead_cores;
-
-		offset = EMU_FUSE_MAPX(i);
-		emu_fuse.value = nitrox_read_csr(ndev, offset);
-		if (emu_fuse.s.valid) {
-			dead_cores = hweight32(emu_fuse.s.ae_fuse);
-			ndev->hw.ae_cores += AE_CORES_PER_CLUSTER - dead_cores;
-			dead_cores = hweight16(emu_fuse.s.se_fuse);
-			ndev->hw.se_cores += SE_CORES_PER_CLUSTER - dead_cores;
-		}
-	}
-}
-
 static int nitrox_pf_hw_init(struct nitrox_device *ndev)
 {
 	int err;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH cryptodev-2.6 2/3] crypto: cavium/nitrox - add support for per device request statistics.
  2018-09-21 11:38 [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Srikanth Jampala
@ 2018-09-21 11:38 ` Srikanth Jampala
  2018-09-21 11:38 ` [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information Srikanth Jampala
  2018-09-28  5:09 ` [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Herbert Xu
  2 siblings, 0 replies; 8+ messages in thread
From: Srikanth Jampala @ 2018-09-21 11:38 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, sgadam, Jampala.Srikanth

Add per device statistics like number of requests posted,
dropped and completed etc.

Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
---
 drivers/crypto/cavium/nitrox/nitrox_dev.h    | 7 +++++++
 drivers/crypto/cavium/nitrox/nitrox_main.c   | 5 +++++
 drivers/crypto/cavium/nitrox/nitrox_reqmgr.c | 9 ++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
index 1059495ee541..a1442006f256 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
@@ -75,6 +75,12 @@ struct nitrox_hw {
 	u8 zip_cores;
 };
 
+struct nitrox_stats {
+	atomic64_t posted;
+	atomic64_t completed;
+	atomic64_t dropped;
+};
+
 #define MAX_MSIX_VECTOR_NAME	20
 /**
  * vectors for queues (64 AE, 64 SE and 64 ZIP) and
@@ -176,6 +182,7 @@ struct nitrox_device {
 	struct nitrox_msix msix;
 	struct nitrox_bh bh;
 
+	struct nitrox_stats stats;
 	struct nitrox_hw hw;
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 	struct dentry *debugfs_dir;
diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
index acce0f0b9c7a..362e7217354c 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -542,6 +542,11 @@ static int nitrox_probe(struct pci_dev *pdev,
 	if (err)
 		goto pf_hw_fail;
 
+	/* clear the statistics */
+	atomic64_set(&ndev->stats.posted, 0);
+	atomic64_set(&ndev->stats.completed, 0);
+	atomic64_set(&ndev->stats.dropped, 0);
+
 	atomic_set(&ndev->state, __NDEV_READY);
 	/* barrier to sync with other cpus */
 	smp_mb__after_atomic();
diff --git a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c
index 4a362fc22f62..f325b48ba904 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c
@@ -460,6 +460,9 @@ static void post_se_instr(struct nitrox_softreq *sr,
 	cmdq->write_idx = incr_index(idx, 1, ndev->qlen);
 
 	spin_unlock_bh(&cmdq->cmdq_lock);
+
+	/* increment the posted command count */
+	atomic64_inc(&ndev->stats.posted);
 }
 
 static int post_backlog_cmds(struct nitrox_cmdq *cmdq)
@@ -508,8 +511,11 @@ static int nitrox_enqueue_request(struct nitrox_softreq *sr)
 	post_backlog_cmds(cmdq);
 
 	if (unlikely(cmdq_full(cmdq, ndev->qlen))) {
-		if (!(sr->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))
+		if (!(sr->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
+			/* increment drop count */
+			atomic64_inc(&ndev->stats.dropped);
 			return -ENOSPC;
+		}
 		/* add to backlog list */
 		backlog_list_add(sr, cmdq);
 		return -EBUSY;
@@ -694,6 +700,7 @@ static void process_response_list(struct nitrox_cmdq *cmdq)
 					    READ_ONCE(sr->resp.orh));
 		}
 		atomic_dec(&cmdq->pending_count);
+		atomic64_inc(&ndev->stats.completed);
 		/* sync with other cpus */
 		smp_mb__after_atomic();
 		/* remove from response list */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.
  2018-09-21 11:38 [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Srikanth Jampala
  2018-09-21 11:38 ` [PATCH cryptodev-2.6 2/3] crypto: cavium/nitrox - add support for per device request statistics Srikanth Jampala
@ 2018-09-21 11:38 ` Srikanth Jampala
  2018-09-28 13:31     ` Ard Biesheuvel
  2018-09-28  5:09 ` [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Herbert Xu
  2 siblings, 1 reply; 8+ messages in thread
From: Srikanth Jampala @ 2018-09-21 11:38 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, sgadam, Jampala.Srikanth

Updated debugfs to provide device partname and frequency etc.
New file "stats" shows the number of requests posted, dropped and
completed.

Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
---
 drivers/crypto/cavium/nitrox/Makefile         |   1 +
 drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 113 +++++++++++++++
 drivers/crypto/cavium/nitrox/nitrox_dev.h     |  13 ++
 drivers/crypto/cavium/nitrox/nitrox_main.c    | 129 ------------------
 4 files changed, 127 insertions(+), 129 deletions(-)
 create mode 100644 drivers/crypto/cavium/nitrox/nitrox_debugfs.c

diff --git a/drivers/crypto/cavium/nitrox/Makefile b/drivers/crypto/cavium/nitrox/Makefile
index 6fcda6b56f7e..e12954791673 100644
--- a/drivers/crypto/cavium/nitrox/Makefile
+++ b/drivers/crypto/cavium/nitrox/Makefile
@@ -9,3 +9,4 @@ n5pf-objs := nitrox_main.o \
 	nitrox_algs.o
 
 n5pf-$(CONFIG_PCI_IOV) += nitrox_sriov.o
+n5pf-$(CONFIG_DEBUG_FS) += nitrox_debugfs.o
diff --git a/drivers/crypto/cavium/nitrox/nitrox_debugfs.c b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
new file mode 100644
index 000000000000..2f1e74ea846e
--- /dev/null
+++ b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/seq_file.h>
+#include <linux/debugfs.h>
+
+#include "nitrox_csr.h"
+#include "nitrox_dev.h"
+
+static int firmware_show(struct seq_file *s, void *v)
+{
+	struct nitrox_device *ndev = s->private;
+
+	seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
+	return 0;
+}
+
+static int firmware_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, firmware_show, inode->i_private);
+}
+
+static const struct file_operations firmware_fops = {
+	.owner = THIS_MODULE,
+	.open = firmware_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static int device_show(struct seq_file *s, void *v)
+{
+	struct nitrox_device *ndev = s->private;
+
+	seq_printf(s, "NITROX [%d]\n", ndev->idx);
+	seq_printf(s, "  Part Name: %s\n", ndev->hw.partname);
+	seq_printf(s, "  Frequency: %d MHz\n", ndev->hw.freq);
+	seq_printf(s, "  Device ID: 0x%0x\n", ndev->hw.device_id);
+	seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
+	seq_printf(s, "  Cores: [AE=%u  SE=%u  ZIP=%u]\n",
+		   ndev->hw.ae_cores, ndev->hw.se_cores, ndev->hw.zip_cores);
+
+	return 0;
+}
+
+static int nitrox_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, device_show, inode->i_private);
+}
+
+static const struct file_operations nitrox_fops = {
+	.owner = THIS_MODULE,
+	.open = nitrox_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static int stats_show(struct seq_file *s, void *v)
+{
+	struct nitrox_device *ndev = s->private;
+
+	seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
+	seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
+	seq_printf(s, "  Completed: %lld\n",
+		   atomic64_read(&ndev->stats.completed));
+	seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
+
+	return 0;
+}
+
+static int nitrox_stats_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, stats_show, inode->i_private);
+}
+
+static const struct file_operations nitrox_stats_fops = {
+	.owner = THIS_MODULE,
+	.open = nitrox_stats_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+void nitrox_debugfs_exit(struct nitrox_device *ndev)
+{
+	debugfs_remove_recursive(ndev->debugfs_dir);
+	ndev->debugfs_dir = NULL;
+}
+
+int nitrox_debugfs_init(struct nitrox_device *ndev)
+{
+	struct dentry *dir, *f;
+
+	dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
+	if (!dir)
+		return -ENOMEM;
+
+	ndev->debugfs_dir = dir;
+	f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
+	if (!f)
+		goto err;
+	f = debugfs_create_file("device", 0400, dir, ndev, &nitrox_fops);
+	if (!f)
+		goto err;
+	f = debugfs_create_file("stats", 0400, dir, ndev, &nitrox_stats_fops);
+	if (!f)
+		goto err;
+
+	return 0;
+
+err:
+	nitrox_debugfs_exit(ndev);
+	return -ENODEV;
+}
diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
index a1442006f256..abb5c8ac54e5 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
+++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
@@ -218,4 +218,17 @@ static inline bool nitrox_ready(struct nitrox_device *ndev)
 	return atomic_read(&ndev->state) == __NDEV_READY;
 }
 
+#ifdef CONFIG_DEBUG_FS
+int nitrox_debugfs_init(struct nitrox_device *ndev);
+void nitrox_debugfs_exit(struct nitrox_device *ndev);
+#else
+static inline int nitrox_debugfs_init(struct nitrox_device *ndev)
+{
+	return 0;
+}
+
+static inline void nitrox_debugfs_exit(struct nitrox_device *ndev)
+{ }
+#endif
+
 #endif /* __NITROX_DEV_H */
diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
index 362e7217354c..5bd97cff1405 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -323,135 +323,6 @@ static int nitrox_pf_hw_init(struct nitrox_device *ndev)
 	return 0;
 }
 
-#if IS_ENABLED(CONFIG_DEBUG_FS)
-static int registers_show(struct seq_file *s, void *v)
-{
-	struct nitrox_device *ndev = s->private;
-	u64 offset;
-
-	/* NPS DMA stats */
-	offset = NPS_STATS_PKT_DMA_RD_CNT;
-	seq_printf(s, "NPS_STATS_PKT_DMA_RD_CNT  0x%016llx\n",
-		   nitrox_read_csr(ndev, offset));
-	offset = NPS_STATS_PKT_DMA_WR_CNT;
-	seq_printf(s, "NPS_STATS_PKT_DMA_WR_CNT  0x%016llx\n",
-		   nitrox_read_csr(ndev, offset));
-
-	/* BMI/BMO stats */
-	offset = BMI_NPS_PKT_CNT;
-	seq_printf(s, "BMI_NPS_PKT_CNT  0x%016llx\n",
-		   nitrox_read_csr(ndev, offset));
-	offset = BMO_NPS_SLC_PKT_CNT;
-	seq_printf(s, "BMO_NPS_PKT_CNT  0x%016llx\n",
-		   nitrox_read_csr(ndev, offset));
-
-	return 0;
-}
-
-static int registers_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, registers_show, inode->i_private);
-}
-
-static const struct file_operations register_fops = {
-	.owner = THIS_MODULE,
-	.open = registers_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-static int firmware_show(struct seq_file *s, void *v)
-{
-	struct nitrox_device *ndev = s->private;
-
-	seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
-	return 0;
-}
-
-static int firmware_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, firmware_show, inode->i_private);
-}
-
-static const struct file_operations firmware_fops = {
-	.owner = THIS_MODULE,
-	.open = firmware_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-static int nitrox_show(struct seq_file *s, void *v)
-{
-	struct nitrox_device *ndev = s->private;
-
-	seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
-	seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
-	seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
-		   ndev->hw.ae_cores, ndev->hw.se_cores);
-	seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);
-	seq_printf(s, "  Queue length: %u\n", ndev->qlen);
-	seq_printf(s, "  Node: %u\n", ndev->node);
-
-	return 0;
-}
-
-static int nitrox_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, nitrox_show, inode->i_private);
-}
-
-static const struct file_operations nitrox_fops = {
-	.owner = THIS_MODULE,
-	.open = nitrox_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-static void nitrox_debugfs_exit(struct nitrox_device *ndev)
-{
-	debugfs_remove_recursive(ndev->debugfs_dir);
-	ndev->debugfs_dir = NULL;
-}
-
-static int nitrox_debugfs_init(struct nitrox_device *ndev)
-{
-	struct dentry *dir, *f;
-
-	dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!dir)
-		return -ENOMEM;
-
-	ndev->debugfs_dir = dir;
-	f = debugfs_create_file("counters", 0400, dir, ndev, &register_fops);
-	if (!f)
-		goto err;
-	f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
-	if (!f)
-		goto err;
-	f = debugfs_create_file("nitrox", 0400, dir, ndev, &nitrox_fops);
-	if (!f)
-		goto err;
-
-	return 0;
-
-err:
-	nitrox_debugfs_exit(ndev);
-	return -ENODEV;
-}
-#else
-static int nitrox_debugfs_init(struct nitrox_device *ndev)
-{
-	return 0;
-}
-
-static void nitrox_debugfs_exit(struct nitrox_device *ndev)
-{
-}
-#endif
-
 /**
  * nitrox_probe - NITROX Initialization function.
  * @pdev: PCI device information struct
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname.
  2018-09-21 11:38 [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Srikanth Jampala
  2018-09-21 11:38 ` [PATCH cryptodev-2.6 2/3] crypto: cavium/nitrox - add support for per device request statistics Srikanth Jampala
  2018-09-21 11:38 ` [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information Srikanth Jampala
@ 2018-09-28  5:09 ` Herbert Xu
  2 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2018-09-28  5:09 UTC (permalink / raw)
  To: Srikanth Jampala; +Cc: davem, linux-crypto, linux-kernel, sgadam

On Fri, Sep 21, 2018 at 05:08:00PM +0530, Srikanth Jampala wrote:
> Get the device partname based on it's capabilities like,
> core frequency, number of cores and revision id.
> 
> Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
> ---
>  drivers/crypto/cavium/nitrox/nitrox_csr.h  | 111 +++++++++++++++++++++
>  drivers/crypto/cavium/nitrox/nitrox_dev.h  |  17 +++-
>  drivers/crypto/cavium/nitrox/nitrox_hal.c  |  57 +++++++++++
>  drivers/crypto/cavium/nitrox/nitrox_hal.h  |   1 +
>  drivers/crypto/cavium/nitrox/nitrox_main.c |  20 ----
>  5 files changed, 184 insertions(+), 22 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.
  2018-09-21 11:38 ` [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information Srikanth Jampala
@ 2018-09-28 13:31     ` Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2018-09-28 13:31 UTC (permalink / raw)
  To: Srikanth Jampala
  Cc: Herbert Xu, David S. Miller,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	Linux Kernel Mailing List, sgadam

On 21 September 2018 at 13:38, Srikanth Jampala
<Jampala.Srikanth@cavium.com> wrote:
> Updated debugfs to provide device partname and frequency etc.
> New file "stats" shows the number of requests posted, dropped and
> completed.
>
> Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
> ---
>  drivers/crypto/cavium/nitrox/Makefile         |   1 +
>  drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 113 +++++++++++++++
>  drivers/crypto/cavium/nitrox/nitrox_dev.h     |  13 ++
>  drivers/crypto/cavium/nitrox/nitrox_main.c    | 129 ------------------
>  4 files changed, 127 insertions(+), 129 deletions(-)
>  create mode 100644 drivers/crypto/cavium/nitrox/nitrox_debugfs.c
>
> diff --git a/drivers/crypto/cavium/nitrox/Makefile b/drivers/crypto/cavium/nitrox/Makefile
> index 6fcda6b56f7e..e12954791673 100644
> --- a/drivers/crypto/cavium/nitrox/Makefile
> +++ b/drivers/crypto/cavium/nitrox/Makefile
> @@ -9,3 +9,4 @@ n5pf-objs := nitrox_main.o \
>         nitrox_algs.o
>
>  n5pf-$(CONFIG_PCI_IOV) += nitrox_sriov.o
> +n5pf-$(CONFIG_DEBUG_FS) += nitrox_debugfs.o
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_debugfs.c b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> new file mode 100644
> index 000000000000..2f1e74ea846e
> --- /dev/null
> +++ b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> @@ -0,0 +1,113 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/seq_file.h>
> +#include <linux/debugfs.h>
> +
> +#include "nitrox_csr.h"
> +#include "nitrox_dev.h"
> +
> +static int firmware_show(struct seq_file *s, void *v)
> +{
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> +       return 0;
> +}
> +
> +static int firmware_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, firmware_show, inode->i_private);
> +}
> +
> +static const struct file_operations firmware_fops = {
> +       .owner = THIS_MODULE,
> +       .open = firmware_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int device_show(struct seq_file *s, void *v)
> +{
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d]\n", ndev->idx);
> +       seq_printf(s, "  Part Name: %s\n", ndev->hw.partname);
> +       seq_printf(s, "  Frequency: %d MHz\n", ndev->hw.freq);
> +       seq_printf(s, "  Device ID: 0x%0x\n", ndev->hw.device_id);
> +       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> +       seq_printf(s, "  Cores: [AE=%u  SE=%u  ZIP=%u]\n",
> +                  ndev->hw.ae_cores, ndev->hw.se_cores, ndev->hw.zip_cores);
> +
> +       return 0;
> +}
> +
> +static int nitrox_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, device_show, inode->i_private);
> +}
> +
> +static const struct file_operations nitrox_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int stats_show(struct seq_file *s, void *v)
> +{
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
> +       seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
> +       seq_printf(s, "  Completed: %lld\n",
> +                  atomic64_read(&ndev->stats.completed));
> +       seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
> +

This gives me

/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c: In
function ‘stats_show’:
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:62:30:
warning: format ‘%lld’ expects argument of type ‘long long int’, but
argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
                              ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:63:33:
warning: format ‘%lld’ expects argument of type ‘long long int’, but
argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Completed: %lld\n",
                                 ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:65:31:
warning: format ‘%lld’ expects argument of type ‘long long int’, but
argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
                               ^

when building on arm64.


> +       return 0;
> +}
> +
> +static int nitrox_stats_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, stats_show, inode->i_private);
> +}
> +
> +static const struct file_operations nitrox_stats_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_stats_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +void nitrox_debugfs_exit(struct nitrox_device *ndev)
> +{
> +       debugfs_remove_recursive(ndev->debugfs_dir);
> +       ndev->debugfs_dir = NULL;
> +}
> +
> +int nitrox_debugfs_init(struct nitrox_device *ndev)
> +{
> +       struct dentry *dir, *f;
> +
> +       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> +       if (!dir)
> +               return -ENOMEM;
> +
> +       ndev->debugfs_dir = dir;
> +       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("device", 0400, dir, ndev, &nitrox_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("stats", 0400, dir, ndev, &nitrox_stats_fops);
> +       if (!f)
> +               goto err;
> +
> +       return 0;
> +
> +err:
> +       nitrox_debugfs_exit(ndev);
> +       return -ENODEV;
> +}
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> index a1442006f256..abb5c8ac54e5 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
> +++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> @@ -218,4 +218,17 @@ static inline bool nitrox_ready(struct nitrox_device *ndev)
>         return atomic_read(&ndev->state) == __NDEV_READY;
>  }
>
> +#ifdef CONFIG_DEBUG_FS
> +int nitrox_debugfs_init(struct nitrox_device *ndev);
> +void nitrox_debugfs_exit(struct nitrox_device *ndev);
> +#else
> +static inline int nitrox_debugfs_init(struct nitrox_device *ndev)
> +{
> +       return 0;
> +}
> +
> +static inline void nitrox_debugfs_exit(struct nitrox_device *ndev)
> +{ }
> +#endif
> +
>  #endif /* __NITROX_DEV_H */
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
> index 362e7217354c..5bd97cff1405 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_main.c
> +++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
> @@ -323,135 +323,6 @@ static int nitrox_pf_hw_init(struct nitrox_device *ndev)
>         return 0;
>  }
>
> -#if IS_ENABLED(CONFIG_DEBUG_FS)
> -static int registers_show(struct seq_file *s, void *v)
> -{
> -       struct nitrox_device *ndev = s->private;
> -       u64 offset;
> -
> -       /* NPS DMA stats */
> -       offset = NPS_STATS_PKT_DMA_RD_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_RD_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = NPS_STATS_PKT_DMA_WR_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_WR_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       /* BMI/BMO stats */
> -       offset = BMI_NPS_PKT_CNT;
> -       seq_printf(s, "BMI_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = BMO_NPS_SLC_PKT_CNT;
> -       seq_printf(s, "BMO_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       return 0;
> -}
> -
> -static int registers_open(struct inode *inode, struct file *file)
> -{
> -       return single_open(file, registers_show, inode->i_private);
> -}
> -
> -static const struct file_operations register_fops = {
> -       .owner = THIS_MODULE,
> -       .open = registers_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int firmware_show(struct seq_file *s, void *v)
> -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> -       return 0;
> -}
> -
> -static int firmware_open(struct inode *inode, struct file *file)
> -{
> -       return single_open(file, firmware_show, inode->i_private);
> -}
> -
> -static const struct file_operations firmware_fops = {
> -       .owner = THIS_MODULE,
> -       .open = firmware_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int nitrox_show(struct seq_file *s, void *v)
> -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
> -       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> -       seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
> -                  ndev->hw.ae_cores, ndev->hw.se_cores);
> -       seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);
> -       seq_printf(s, "  Queue length: %u\n", ndev->qlen);
> -       seq_printf(s, "  Node: %u\n", ndev->node);
> -
> -       return 0;
> -}
> -
> -static int nitrox_open(struct inode *inode, struct file *file)
> -{
> -       return single_open(file, nitrox_show, inode->i_private);
> -}
> -
> -static const struct file_operations nitrox_fops = {
> -       .owner = THIS_MODULE,
> -       .open = nitrox_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev)
> -{
> -       debugfs_remove_recursive(ndev->debugfs_dir);
> -       ndev->debugfs_dir = NULL;
> -}
> -
> -static int nitrox_debugfs_init(struct nitrox_device *ndev)
> -{
> -       struct dentry *dir, *f;
> -
> -       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> -       if (!dir)
> -               return -ENOMEM;
> -
> -       ndev->debugfs_dir = dir;
> -       f = debugfs_create_file("counters", 0400, dir, ndev, &register_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("nitrox", 0400, dir, ndev, &nitrox_fops);
> -       if (!f)
> -               goto err;
> -
> -       return 0;
> -
> -err:
> -       nitrox_debugfs_exit(ndev);
> -       return -ENODEV;
> -}
> -#else
> -static int nitrox_debugfs_init(struct nitrox_device *ndev)
> -{
> -       return 0;
> -}
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev)
> -{
> -}
> -#endif
> -
>  /**
>   * nitrox_probe - NITROX Initialization function.
>   * @pdev: PCI device information struct
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.
@ 2018-09-28 13:31     ` Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2018-09-28 13:31 UTC (permalink / raw)
  To: Srikanth Jampala
  Cc: Herbert Xu, David S. Miller,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	Linux Kernel Mailing List, sgadam

On 21 September 2018 at 13:38, Srikanth Jampala
<Jampala.Srikanth@cavium.com> wrote:
> Updated debugfs to provide device partname and frequency etc.
> New file "stats" shows the number of requests posted, dropped and
> completed.
>
> Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
> ---
>  drivers/crypto/cavium/nitrox/Makefile         |   1 +
>  drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 113 +++++++++++++++
>  drivers/crypto/cavium/nitrox/nitrox_dev.h     |  13 ++
>  drivers/crypto/cavium/nitrox/nitrox_main.c    | 129 ------------------
>  4 files changed, 127 insertions(+), 129 deletions(-)
>  create mode 100644 drivers/crypto/cavium/nitrox/nitrox_debugfs.c
>
> diff --git a/drivers/crypto/cavium/nitrox/Makefile b/drivers/crypto/cavium/nitrox/Makefile
> index 6fcda6b56f7e..e12954791673 100644
> --- a/drivers/crypto/cavium/nitrox/Makefile
> +++ b/drivers/crypto/cavium/nitrox/Makefile
> @@ -9,3 +9,4 @@ n5pf-objs := nitrox_main.o \
>         nitrox_algs.o
>
>  n5pf-$(CONFIG_PCI_IOV) += nitrox_sriov.o
> +n5pf-$(CONFIG_DEBUG_FS) += nitrox_debugfs.o
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_debugfs.c b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> new file mode 100644
> index 000000000000..2f1e74ea846e
> --- /dev/null
> +++ b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> @@ -0,0 +1,113 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/seq_file.h>
> +#include <linux/debugfs.h>
> +
> +#include "nitrox_csr.h"
> +#include "nitrox_dev.h"
> +
> +static int firmware_show(struct seq_file *s, void *v)
> +{
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> +       return 0;
> +}
> +
> +static int firmware_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, firmware_show, inode->i_private);
> +}
> +
> +static const struct file_operations firmware_fops = {
> +       .owner = THIS_MODULE,
> +       .open = firmware_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int device_show(struct seq_file *s, void *v)
> +{
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d]\n", ndev->idx);
> +       seq_printf(s, "  Part Name: %s\n", ndev->hw.partname);
> +       seq_printf(s, "  Frequency: %d MHz\n", ndev->hw.freq);
> +       seq_printf(s, "  Device ID: 0x%0x\n", ndev->hw.device_id);
> +       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> +       seq_printf(s, "  Cores: [AE=%u  SE=%u  ZIP=%u]\n",
> +                  ndev->hw.ae_cores, ndev->hw.se_cores, ndev->hw.zip_cores);
> +
> +       return 0;
> +}
> +
> +static int nitrox_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, device_show, inode->i_private);
> +}
> +
> +static const struct file_operations nitrox_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int stats_show(struct seq_file *s, void *v)
> +{
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
> +       seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
> +       seq_printf(s, "  Completed: %lld\n",
> +                  atomic64_read(&ndev->stats.completed));
> +       seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
> +

This gives me

/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c: In
function ‘stats_show’:
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:62:30:
warning: format ‘%lld’ expects argument of type ‘long long int’, but
argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
                              ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:63:33:
warning: format ‘%lld’ expects argument of type ‘long long int’, but
argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Completed: %lld\n",
                                 ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:65:31:
warning: format ‘%lld’ expects argument of type ‘long long int’, but
argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
                               ^

when building on arm64.


> +       return 0;
> +}
> +
> +static int nitrox_stats_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, stats_show, inode->i_private);
> +}
> +
> +static const struct file_operations nitrox_stats_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_stats_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +void nitrox_debugfs_exit(struct nitrox_device *ndev)
> +{
> +       debugfs_remove_recursive(ndev->debugfs_dir);
> +       ndev->debugfs_dir = NULL;
> +}
> +
> +int nitrox_debugfs_init(struct nitrox_device *ndev)
> +{
> +       struct dentry *dir, *f;
> +
> +       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> +       if (!dir)
> +               return -ENOMEM;
> +
> +       ndev->debugfs_dir = dir;
> +       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("device", 0400, dir, ndev, &nitrox_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("stats", 0400, dir, ndev, &nitrox_stats_fops);
> +       if (!f)
> +               goto err;
> +
> +       return 0;
> +
> +err:
> +       nitrox_debugfs_exit(ndev);
> +       return -ENODEV;
> +}
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> index a1442006f256..abb5c8ac54e5 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
> +++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> @@ -218,4 +218,17 @@ static inline bool nitrox_ready(struct nitrox_device *ndev)
>         return atomic_read(&ndev->state) == __NDEV_READY;
>  }
>
> +#ifdef CONFIG_DEBUG_FS
> +int nitrox_debugfs_init(struct nitrox_device *ndev);
> +void nitrox_debugfs_exit(struct nitrox_device *ndev);
> +#else
> +static inline int nitrox_debugfs_init(struct nitrox_device *ndev)
> +{
> +       return 0;
> +}
> +
> +static inline void nitrox_debugfs_exit(struct nitrox_device *ndev)
> +{ }
> +#endif
> +
>  #endif /* __NITROX_DEV_H */
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
> index 362e7217354c..5bd97cff1405 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_main.c
> +++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
> @@ -323,135 +323,6 @@ static int nitrox_pf_hw_init(struct nitrox_device *ndev)
>         return 0;
>  }
>
> -#if IS_ENABLED(CONFIG_DEBUG_FS)
> -static int registers_show(struct seq_file *s, void *v)
> -{
> -       struct nitrox_device *ndev = s->private;
> -       u64 offset;
> -
> -       /* NPS DMA stats */
> -       offset = NPS_STATS_PKT_DMA_RD_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_RD_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = NPS_STATS_PKT_DMA_WR_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_WR_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       /* BMI/BMO stats */
> -       offset = BMI_NPS_PKT_CNT;
> -       seq_printf(s, "BMI_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = BMO_NPS_SLC_PKT_CNT;
> -       seq_printf(s, "BMO_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       return 0;
> -}
> -
> -static int registers_open(struct inode *inode, struct file *file)
> -{
> -       return single_open(file, registers_show, inode->i_private);
> -}
> -
> -static const struct file_operations register_fops = {
> -       .owner = THIS_MODULE,
> -       .open = registers_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int firmware_show(struct seq_file *s, void *v)
> -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> -       return 0;
> -}
> -
> -static int firmware_open(struct inode *inode, struct file *file)
> -{
> -       return single_open(file, firmware_show, inode->i_private);
> -}
> -
> -static const struct file_operations firmware_fops = {
> -       .owner = THIS_MODULE,
> -       .open = firmware_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int nitrox_show(struct seq_file *s, void *v)
> -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
> -       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> -       seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
> -                  ndev->hw.ae_cores, ndev->hw.se_cores);
> -       seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);
> -       seq_printf(s, "  Queue length: %u\n", ndev->qlen);
> -       seq_printf(s, "  Node: %u\n", ndev->node);
> -
> -       return 0;
> -}
> -
> -static int nitrox_open(struct inode *inode, struct file *file)
> -{
> -       return single_open(file, nitrox_show, inode->i_private);
> -}
> -
> -static const struct file_operations nitrox_fops = {
> -       .owner = THIS_MODULE,
> -       .open = nitrox_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev)
> -{
> -       debugfs_remove_recursive(ndev->debugfs_dir);
> -       ndev->debugfs_dir = NULL;
> -}
> -
> -static int nitrox_debugfs_init(struct nitrox_device *ndev)
> -{
> -       struct dentry *dir, *f;
> -
> -       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> -       if (!dir)
> -               return -ENOMEM;
> -
> -       ndev->debugfs_dir = dir;
> -       f = debugfs_create_file("counters", 0400, dir, ndev, &register_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("nitrox", 0400, dir, ndev, &nitrox_fops);
> -       if (!f)
> -               goto err;
> -
> -       return 0;
> -
> -err:
> -       nitrox_debugfs_exit(ndev);
> -       return -ENODEV;
> -}
> -#else
> -static int nitrox_debugfs_init(struct nitrox_device *ndev)
> -{
> -       return 0;
> -}
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev)
> -{
> -}
> -#endif
> -
>  /**
>   * nitrox_probe - NITROX Initialization function.
>   * @pdev: PCI device information struct
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.
  2018-09-28 13:31     ` Ard Biesheuvel
@ 2018-09-28 14:41       ` Srikanth, Jampala
  -1 siblings, 0 replies; 8+ messages in thread
From: Srikanth, Jampala @ 2018-09-28 14:41 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Herbert Xu, David S. Miller,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	Linux Kernel Mailing List, Gadam, Sreerama

Hey Ard,

Thanks a lot for your feedback. I will post the fixes soon.

-----Original Message-----
From: Ard Biesheuvel <ard.biesheuvel@linaro.org> 
Sent: 28 September 2018 19:02
To: Srikanth, Jampala <Jampala.Srikanth@cavium.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>; David S. Miller <davem@davemloft.net>; open list:HARDWARE RANDOM NUMBER GENERATOR CORE <linux-crypto@vger.kernel.org>; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; Gadam, Sreerama <Sreerama.Gadam@cavium.com>
Subject: Re: [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.

External Email

On 21 September 2018 at 13:38, Srikanth Jampala <Jampala.Srikanth@cavium.com> wrote:
> Updated debugfs to provide device partname and frequency etc.
> New file "stats" shows the number of requests posted, dropped and 
> completed.
>
> Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
> ---
>  drivers/crypto/cavium/nitrox/Makefile         |   1 +
>  drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 113 +++++++++++++++
>  drivers/crypto/cavium/nitrox/nitrox_dev.h     |  13 ++
>  drivers/crypto/cavium/nitrox/nitrox_main.c    | 129 ------------------
>  4 files changed, 127 insertions(+), 129 deletions(-)  create mode 
> 100644 drivers/crypto/cavium/nitrox/nitrox_debugfs.c
>
> diff --git a/drivers/crypto/cavium/nitrox/Makefile 
> b/drivers/crypto/cavium/nitrox/Makefile
> index 6fcda6b56f7e..e12954791673 100644
> --- a/drivers/crypto/cavium/nitrox/Makefile
> +++ b/drivers/crypto/cavium/nitrox/Makefile
> @@ -9,3 +9,4 @@ n5pf-objs := nitrox_main.o \
>         nitrox_algs.o
>
>  n5pf-$(CONFIG_PCI_IOV) += nitrox_sriov.o
> +n5pf-$(CONFIG_DEBUG_FS) += nitrox_debugfs.o
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_debugfs.c 
> b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> new file mode 100644
> index 000000000000..2f1e74ea846e
> --- /dev/null
> +++ b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> @@ -0,0 +1,113 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/seq_file.h>
> +#include <linux/debugfs.h>
> +
> +#include "nitrox_csr.h"
> +#include "nitrox_dev.h"
> +
> +static int firmware_show(struct seq_file *s, void *v) {
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> +       return 0;
> +}
> +
> +static int firmware_open(struct inode *inode, struct file *file) {
> +       return single_open(file, firmware_show, inode->i_private); }
> +
> +static const struct file_operations firmware_fops = {
> +       .owner = THIS_MODULE,
> +       .open = firmware_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int device_show(struct seq_file *s, void *v) {
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d]\n", ndev->idx);
> +       seq_printf(s, "  Part Name: %s\n", ndev->hw.partname);
> +       seq_printf(s, "  Frequency: %d MHz\n", ndev->hw.freq);
> +       seq_printf(s, "  Device ID: 0x%0x\n", ndev->hw.device_id);
> +       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> +       seq_printf(s, "  Cores: [AE=%u  SE=%u  ZIP=%u]\n",
> +                  ndev->hw.ae_cores, ndev->hw.se_cores, 
> + ndev->hw.zip_cores);
> +
> +       return 0;
> +}
> +
> +static int nitrox_open(struct inode *inode, struct file *file) {
> +       return single_open(file, device_show, inode->i_private); }
> +
> +static const struct file_operations nitrox_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int stats_show(struct seq_file *s, void *v) {
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
> +       seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
> +       seq_printf(s, "  Completed: %lld\n",
> +                  atomic64_read(&ndev->stats.completed));
> +       seq_printf(s, "  Dropped: %lld\n", 
> + atomic64_read(&ndev->stats.dropped));
> +

This gives me

/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c: In function ‘stats_show’:
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:62:30:
warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
                              ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:63:33:
warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Completed: %lld\n",
                                 ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:65:31:
warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
                               ^

when building on arm64.


> +       return 0;
> +}
> +
> +static int nitrox_stats_open(struct inode *inode, struct file *file) 
> +{
> +       return single_open(file, stats_show, inode->i_private); }
> +
> +static const struct file_operations nitrox_stats_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_stats_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +void nitrox_debugfs_exit(struct nitrox_device *ndev) {
> +       debugfs_remove_recursive(ndev->debugfs_dir);
> +       ndev->debugfs_dir = NULL;
> +}
> +
> +int nitrox_debugfs_init(struct nitrox_device *ndev) {
> +       struct dentry *dir, *f;
> +
> +       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> +       if (!dir)
> +               return -ENOMEM;
> +
> +       ndev->debugfs_dir = dir;
> +       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("device", 0400, dir, ndev, &nitrox_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("stats", 0400, dir, ndev, &nitrox_stats_fops);
> +       if (!f)
> +               goto err;
> +
> +       return 0;
> +
> +err:
> +       nitrox_debugfs_exit(ndev);
> +       return -ENODEV;
> +}
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h 
> b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> index a1442006f256..abb5c8ac54e5 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
> +++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> @@ -218,4 +218,17 @@ static inline bool nitrox_ready(struct nitrox_device *ndev)
>         return atomic_read(&ndev->state) == __NDEV_READY;  }
>
> +#ifdef CONFIG_DEBUG_FS
> +int nitrox_debugfs_init(struct nitrox_device *ndev); void 
> +nitrox_debugfs_exit(struct nitrox_device *ndev); #else static inline 
> +int nitrox_debugfs_init(struct nitrox_device *ndev) {
> +       return 0;
> +}
> +
> +static inline void nitrox_debugfs_exit(struct nitrox_device *ndev) { 
> +} #endif
> +
>  #endif /* __NITROX_DEV_H */
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c 
> b/drivers/crypto/cavium/nitrox/nitrox_main.c
> index 362e7217354c..5bd97cff1405 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_main.c
> +++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
> @@ -323,135 +323,6 @@ static int nitrox_pf_hw_init(struct nitrox_device *ndev)
>         return 0;
>  }
>
> -#if IS_ENABLED(CONFIG_DEBUG_FS)
> -static int registers_show(struct seq_file *s, void *v) -{
> -       struct nitrox_device *ndev = s->private;
> -       u64 offset;
> -
> -       /* NPS DMA stats */
> -       offset = NPS_STATS_PKT_DMA_RD_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_RD_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = NPS_STATS_PKT_DMA_WR_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_WR_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       /* BMI/BMO stats */
> -       offset = BMI_NPS_PKT_CNT;
> -       seq_printf(s, "BMI_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = BMO_NPS_SLC_PKT_CNT;
> -       seq_printf(s, "BMO_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       return 0;
> -}
> -
> -static int registers_open(struct inode *inode, struct file *file) -{
> -       return single_open(file, registers_show, inode->i_private);
> -}
> -
> -static const struct file_operations register_fops = {
> -       .owner = THIS_MODULE,
> -       .open = registers_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int firmware_show(struct seq_file *s, void *v) -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> -       return 0;
> -}
> -
> -static int firmware_open(struct inode *inode, struct file *file) -{
> -       return single_open(file, firmware_show, inode->i_private);
> -}
> -
> -static const struct file_operations firmware_fops = {
> -       .owner = THIS_MODULE,
> -       .open = firmware_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int nitrox_show(struct seq_file *s, void *v) -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
> -       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> -       seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
> -                  ndev->hw.ae_cores, ndev->hw.se_cores);
> -       seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);
> -       seq_printf(s, "  Queue length: %u\n", ndev->qlen);
> -       seq_printf(s, "  Node: %u\n", ndev->node);
> -
> -       return 0;
> -}
> -
> -static int nitrox_open(struct inode *inode, struct file *file) -{
> -       return single_open(file, nitrox_show, inode->i_private);
> -}
> -
> -static const struct file_operations nitrox_fops = {
> -       .owner = THIS_MODULE,
> -       .open = nitrox_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev) -{
> -       debugfs_remove_recursive(ndev->debugfs_dir);
> -       ndev->debugfs_dir = NULL;
> -}
> -
> -static int nitrox_debugfs_init(struct nitrox_device *ndev) -{
> -       struct dentry *dir, *f;
> -
> -       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> -       if (!dir)
> -               return -ENOMEM;
> -
> -       ndev->debugfs_dir = dir;
> -       f = debugfs_create_file("counters", 0400, dir, ndev, &register_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("nitrox", 0400, dir, ndev, &nitrox_fops);
> -       if (!f)
> -               goto err;
> -
> -       return 0;
> -
> -err:
> -       nitrox_debugfs_exit(ndev);
> -       return -ENODEV;
> -}
> -#else
> -static int nitrox_debugfs_init(struct nitrox_device *ndev) -{
> -       return 0;
> -}
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev) -{ -} 
> -#endif
> -
>  /**
>   * nitrox_probe - NITROX Initialization function.
>   * @pdev: PCI device information struct
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.
@ 2018-09-28 14:41       ` Srikanth, Jampala
  0 siblings, 0 replies; 8+ messages in thread
From: Srikanth, Jampala @ 2018-09-28 14:41 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Herbert Xu, David S. Miller,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	Linux Kernel Mailing List, Gadam, Sreerama

Hey Ard,

Thanks a lot for your feedback. I will post the fixes soon.

-----Original Message-----
From: Ard Biesheuvel <ard.biesheuvel@linaro.org> 
Sent: 28 September 2018 19:02
To: Srikanth, Jampala <Jampala.Srikanth@cavium.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>; David S. Miller <davem@davemloft.net>; open list:HARDWARE RANDOM NUMBER GENERATOR CORE <linux-crypto@vger.kernel.org>; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; Gadam, Sreerama <Sreerama.Gadam@cavium.com>
Subject: Re: [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information.

External Email

On 21 September 2018 at 13:38, Srikanth Jampala <Jampala.Srikanth@cavium.com> wrote:
> Updated debugfs to provide device partname and frequency etc.
> New file "stats" shows the number of requests posted, dropped and 
> completed.
>
> Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
> ---
>  drivers/crypto/cavium/nitrox/Makefile         |   1 +
>  drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 113 +++++++++++++++
>  drivers/crypto/cavium/nitrox/nitrox_dev.h     |  13 ++
>  drivers/crypto/cavium/nitrox/nitrox_main.c    | 129 ------------------
>  4 files changed, 127 insertions(+), 129 deletions(-)  create mode 
> 100644 drivers/crypto/cavium/nitrox/nitrox_debugfs.c
>
> diff --git a/drivers/crypto/cavium/nitrox/Makefile 
> b/drivers/crypto/cavium/nitrox/Makefile
> index 6fcda6b56f7e..e12954791673 100644
> --- a/drivers/crypto/cavium/nitrox/Makefile
> +++ b/drivers/crypto/cavium/nitrox/Makefile
> @@ -9,3 +9,4 @@ n5pf-objs := nitrox_main.o \
>         nitrox_algs.o
>
>  n5pf-$(CONFIG_PCI_IOV) += nitrox_sriov.o
> +n5pf-$(CONFIG_DEBUG_FS) += nitrox_debugfs.o
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_debugfs.c 
> b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> new file mode 100644
> index 000000000000..2f1e74ea846e
> --- /dev/null
> +++ b/drivers/crypto/cavium/nitrox/nitrox_debugfs.c
> @@ -0,0 +1,113 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/seq_file.h>
> +#include <linux/debugfs.h>
> +
> +#include "nitrox_csr.h"
> +#include "nitrox_dev.h"
> +
> +static int firmware_show(struct seq_file *s, void *v) {
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> +       return 0;
> +}
> +
> +static int firmware_open(struct inode *inode, struct file *file) {
> +       return single_open(file, firmware_show, inode->i_private); }
> +
> +static const struct file_operations firmware_fops = {
> +       .owner = THIS_MODULE,
> +       .open = firmware_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int device_show(struct seq_file *s, void *v) {
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d]\n", ndev->idx);
> +       seq_printf(s, "  Part Name: %s\n", ndev->hw.partname);
> +       seq_printf(s, "  Frequency: %d MHz\n", ndev->hw.freq);
> +       seq_printf(s, "  Device ID: 0x%0x\n", ndev->hw.device_id);
> +       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> +       seq_printf(s, "  Cores: [AE=%u  SE=%u  ZIP=%u]\n",
> +                  ndev->hw.ae_cores, ndev->hw.se_cores, 
> + ndev->hw.zip_cores);
> +
> +       return 0;
> +}
> +
> +static int nitrox_open(struct inode *inode, struct file *file) {
> +       return single_open(file, device_show, inode->i_private); }
> +
> +static const struct file_operations nitrox_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static int stats_show(struct seq_file *s, void *v) {
> +       struct nitrox_device *ndev = s->private;
> +
> +       seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
> +       seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
> +       seq_printf(s, "  Completed: %lld\n",
> +                  atomic64_read(&ndev->stats.completed));
> +       seq_printf(s, "  Dropped: %lld\n", 
> + atomic64_read(&ndev->stats.dropped));
> +

This gives me

/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c: In function ‘stats_show’:
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:62:30:
warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Posted: %lld\n", atomic64_read(&ndev->stats.posted));
                              ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:63:33:
warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Completed: %lld\n",
                                 ^
/home/ard/linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c:65:31:
warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int’ [-Wformat=]
  seq_printf(s, "  Dropped: %lld\n", atomic64_read(&ndev->stats.dropped));
                               ^

when building on arm64.


> +       return 0;
> +}
> +
> +static int nitrox_stats_open(struct inode *inode, struct file *file) 
> +{
> +       return single_open(file, stats_show, inode->i_private); }
> +
> +static const struct file_operations nitrox_stats_fops = {
> +       .owner = THIS_MODULE,
> +       .open = nitrox_stats_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +void nitrox_debugfs_exit(struct nitrox_device *ndev) {
> +       debugfs_remove_recursive(ndev->debugfs_dir);
> +       ndev->debugfs_dir = NULL;
> +}
> +
> +int nitrox_debugfs_init(struct nitrox_device *ndev) {
> +       struct dentry *dir, *f;
> +
> +       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> +       if (!dir)
> +               return -ENOMEM;
> +
> +       ndev->debugfs_dir = dir;
> +       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("device", 0400, dir, ndev, &nitrox_fops);
> +       if (!f)
> +               goto err;
> +       f = debugfs_create_file("stats", 0400, dir, ndev, &nitrox_stats_fops);
> +       if (!f)
> +               goto err;
> +
> +       return 0;
> +
> +err:
> +       nitrox_debugfs_exit(ndev);
> +       return -ENODEV;
> +}
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h 
> b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> index a1442006f256..abb5c8ac54e5 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
> +++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
> @@ -218,4 +218,17 @@ static inline bool nitrox_ready(struct nitrox_device *ndev)
>         return atomic_read(&ndev->state) == __NDEV_READY;  }
>
> +#ifdef CONFIG_DEBUG_FS
> +int nitrox_debugfs_init(struct nitrox_device *ndev); void 
> +nitrox_debugfs_exit(struct nitrox_device *ndev); #else static inline 
> +int nitrox_debugfs_init(struct nitrox_device *ndev) {
> +       return 0;
> +}
> +
> +static inline void nitrox_debugfs_exit(struct nitrox_device *ndev) { 
> +} #endif
> +
>  #endif /* __NITROX_DEV_H */
> diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c 
> b/drivers/crypto/cavium/nitrox/nitrox_main.c
> index 362e7217354c..5bd97cff1405 100644
> --- a/drivers/crypto/cavium/nitrox/nitrox_main.c
> +++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
> @@ -323,135 +323,6 @@ static int nitrox_pf_hw_init(struct nitrox_device *ndev)
>         return 0;
>  }
>
> -#if IS_ENABLED(CONFIG_DEBUG_FS)
> -static int registers_show(struct seq_file *s, void *v) -{
> -       struct nitrox_device *ndev = s->private;
> -       u64 offset;
> -
> -       /* NPS DMA stats */
> -       offset = NPS_STATS_PKT_DMA_RD_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_RD_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = NPS_STATS_PKT_DMA_WR_CNT;
> -       seq_printf(s, "NPS_STATS_PKT_DMA_WR_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       /* BMI/BMO stats */
> -       offset = BMI_NPS_PKT_CNT;
> -       seq_printf(s, "BMI_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -       offset = BMO_NPS_SLC_PKT_CNT;
> -       seq_printf(s, "BMO_NPS_PKT_CNT  0x%016llx\n",
> -                  nitrox_read_csr(ndev, offset));
> -
> -       return 0;
> -}
> -
> -static int registers_open(struct inode *inode, struct file *file) -{
> -       return single_open(file, registers_show, inode->i_private);
> -}
> -
> -static const struct file_operations register_fops = {
> -       .owner = THIS_MODULE,
> -       .open = registers_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int firmware_show(struct seq_file *s, void *v) -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
> -       return 0;
> -}
> -
> -static int firmware_open(struct inode *inode, struct file *file) -{
> -       return single_open(file, firmware_show, inode->i_private);
> -}
> -
> -static const struct file_operations firmware_fops = {
> -       .owner = THIS_MODULE,
> -       .open = firmware_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static int nitrox_show(struct seq_file *s, void *v) -{
> -       struct nitrox_device *ndev = s->private;
> -
> -       seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
> -       seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> -       seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
> -                  ndev->hw.ae_cores, ndev->hw.se_cores);
> -       seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);
> -       seq_printf(s, "  Queue length: %u\n", ndev->qlen);
> -       seq_printf(s, "  Node: %u\n", ndev->node);
> -
> -       return 0;
> -}
> -
> -static int nitrox_open(struct inode *inode, struct file *file) -{
> -       return single_open(file, nitrox_show, inode->i_private);
> -}
> -
> -static const struct file_operations nitrox_fops = {
> -       .owner = THIS_MODULE,
> -       .open = nitrox_open,
> -       .read = seq_read,
> -       .llseek = seq_lseek,
> -       .release = single_release,
> -};
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev) -{
> -       debugfs_remove_recursive(ndev->debugfs_dir);
> -       ndev->debugfs_dir = NULL;
> -}
> -
> -static int nitrox_debugfs_init(struct nitrox_device *ndev) -{
> -       struct dentry *dir, *f;
> -
> -       dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> -       if (!dir)
> -               return -ENOMEM;
> -
> -       ndev->debugfs_dir = dir;
> -       f = debugfs_create_file("counters", 0400, dir, ndev, &register_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
> -       if (!f)
> -               goto err;
> -       f = debugfs_create_file("nitrox", 0400, dir, ndev, &nitrox_fops);
> -       if (!f)
> -               goto err;
> -
> -       return 0;
> -
> -err:
> -       nitrox_debugfs_exit(ndev);
> -       return -ENODEV;
> -}
> -#else
> -static int nitrox_debugfs_init(struct nitrox_device *ndev) -{
> -       return 0;
> -}
> -
> -static void nitrox_debugfs_exit(struct nitrox_device *ndev) -{ -} 
> -#endif
> -
>  /**
>   * nitrox_probe - NITROX Initialization function.
>   * @pdev: PCI device information struct
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-28 14:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21 11:38 [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Srikanth Jampala
2018-09-21 11:38 ` [PATCH cryptodev-2.6 2/3] crypto: cavium/nitrox - add support for per device request statistics Srikanth Jampala
2018-09-21 11:38 ` [PATCH cryptodev-2.6 3/3] crypto: cavium/nitrox - updated debugfs information Srikanth Jampala
2018-09-28 13:31   ` Ard Biesheuvel
2018-09-28 13:31     ` Ard Biesheuvel
2018-09-28 14:41     ` Srikanth, Jampala
2018-09-28 14:41       ` Srikanth, Jampala
2018-09-28  5:09 ` [PATCH cryptodev-2.6 1/3] crypto: cavium/nitrox - added support to identify the NITROX device partname Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.