From: Srinivas Goud <srinivas.goud@amd.com>
To: <wg@grandegger.com>, <mkl@pengutronix.de>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<gcnu.goud@gmail.com>
Cc: <git@amd.com>, <michal.simek@xilinx.com>,
<linux-can@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Srinivas Goud <srinivas.goud@amd.com>
Subject: [PATCH 3/3] can: xilinx_can: Add debugfs support for ECC
Date: Mon, 12 Jun 2023 17:12:57 +0530 [thread overview]
Message-ID: <1686570177-2836108-4-git-send-email-srinivas.goud@amd.com> (raw)
In-Reply-To: <1686570177-2836108-1-git-send-email-srinivas.goud@amd.com>
Create debugfs entry for reading all the FIFO ECC errors.
Signed-off-by: Srinivas Goud <srinivas.goud@amd.com>
---
drivers/net/can/xilinx_can.c | 62 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 311e435..f7bf31a 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -29,6 +29,7 @@
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/pm_runtime.h>
+#include <linux/debugfs.h>
#define DRIVER_NAME "xilinx_can"
@@ -183,6 +184,9 @@ enum xcan_reg {
#define XCAN_FLAG_RX_FIFO_MULTI 0x0010
#define XCAN_FLAG_CANFD_2 0x0020
+/* ECC counters buffer length */
+#define XCAN_ECC_CNT_BUF_LEN 100
+
enum xcan_ip_type {
XAXI_CAN = 0,
XZYNQ_CANPS,
@@ -222,6 +226,7 @@ struct xcan_devtype_data {
* @ecc_1bit_txolfifo_cnt: TXOLFIFO 1bit ECC count
* @ecc_2bit_txtlfifo_cnt: TXTLFIFO 2bit ECC count
* @ecc_1bit_txtlfifo_cnt: TXTLFIFO 1bit ECC count
+ * @debugfs: Directory entry for debugfs
*/
struct xcan_priv {
struct can_priv can;
@@ -246,6 +251,7 @@ struct xcan_priv {
u32 ecc_1bit_txolfifo_cnt;
u32 ecc_2bit_txtlfifo_cnt;
u32 ecc_1bit_txtlfifo_cnt;
+ struct dentry *debugfs;
};
/* CAN Bittiming constants as per Xilinx CAN specs */
@@ -1736,6 +1742,56 @@ static int __maybe_unused xcan_runtime_resume(struct device *dev)
return 0;
}
+static ssize_t read_ecc_cnt_status(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ unsigned int len = 0, buf_len = XCAN_ECC_CNT_BUF_LEN;
+ struct net_device *ndev = file->private_data;
+ struct xcan_priv *priv = netdev_priv(ndev);
+ ssize_t ret_cnt;
+ char *buf;
+
+ buf = kzalloc(buf_len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ len = scnprintf(buf + len, buf_len - len,
+ "%d\n", priv->ecc_2bit_rxfifo_cnt);
+ len += scnprintf(buf + len, buf_len - len,
+ "%d\n", priv->ecc_1bit_rxfifo_cnt);
+ len += scnprintf(buf + len, buf_len - len,
+ "%d\n", priv->ecc_2bit_txolfifo_cnt);
+ len += scnprintf(buf + len, buf_len - len,
+ "%d\n", priv->ecc_1bit_txolfifo_cnt);
+ len += scnprintf(buf + len, buf_len - len,
+ "%d\n", priv->ecc_2bit_txtlfifo_cnt);
+ len += scnprintf(buf + len, buf_len - len,
+ "%d\n", priv->ecc_1bit_txtlfifo_cnt);
+ ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+
+ kfree(buf);
+
+ return ret_cnt;
+}
+
+static const struct file_operations read_ecc_fops = {
+ .open = simple_open,
+ .read = read_ecc_cnt_status,
+ .llseek = generic_file_llseek,
+};
+
+static void setup_debugfs(struct net_device *ndev)
+{
+ struct xcan_priv *priv = netdev_priv(ndev);
+
+ priv->debugfs = debugfs_create_dir(dev_name(priv->dev), NULL);
+ if (!priv->debugfs)
+ return;
+
+ debugfs_create_file("read_ecc_cnt", 0644, priv->debugfs,
+ ndev, &read_ecc_fops);
+}
+
static const struct dev_pm_ops xcan_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(xcan_suspend, xcan_resume)
SET_RUNTIME_PM_OPS(xcan_runtime_suspend, xcan_runtime_resume, NULL)
@@ -1974,10 +2030,12 @@ static int xcan_probe(struct platform_device *pdev)
priv->reg_base, ndev->irq, priv->can.clock.freq,
hw_tx_max, priv->tx_max);
- if (priv->ecc_enable)
+ if (priv->ecc_enable) {
+ setup_debugfs(ndev);
/* Reset FIFO ECC counters */
priv->write_reg(priv, XCAN_ECC_CFG_OFFSET, XCAN_ECC_CFG_REECRX_MASK |
XCAN_ECC_CFG_REECTXOL_MASK | XCAN_ECC_CFG_REECTXTL_MASK);
+ }
return 0;
@@ -2000,7 +2058,9 @@ static int xcan_probe(struct platform_device *pdev)
static int xcan_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
+ struct xcan_priv *priv = netdev_priv(ndev);
+ debugfs_remove_recursive(priv->debugfs);
unregister_candev(ndev);
pm_runtime_disable(&pdev->dev);
free_candev(ndev);
--
2.1.1
next prev parent reply other threads:[~2023-06-12 11:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 11:42 [PATCH 0/3] can: xilinx_can: Add ECC feature support Srinivas Goud
2023-06-12 11:42 ` [PATCH 1/3] dt-bindings: can: xilinx_can: Add ECC property ‘xlnx,has-ecc’ Srinivas Goud
2023-06-13 7:52 ` Marc Kleine-Budde
2023-06-14 10:22 ` Goud, Srinivas
2023-06-14 11:11 ` Krzysztof Kozlowski
2023-06-16 10:13 ` Goud, Srinivas
2023-06-16 10:38 ` Krzysztof Kozlowski
2023-06-16 10:44 ` Michal Simek
2023-06-17 7:31 ` Krzysztof Kozlowski
2023-06-19 6:37 ` Michal Simek
2023-06-17 7:32 ` Krzysztof Kozlowski
2023-06-13 8:46 ` Krzysztof Kozlowski
2023-06-12 11:42 ` [PATCH 2/3] can: xilinx_can: Add ECC support Srinivas Goud
2023-06-13 11:30 ` Marc Kleine-Budde
2023-07-21 5:23 ` Goud, Srinivas
2023-07-24 8:54 ` Marc Kleine-Budde
2023-06-16 11:06 ` Marc Kleine-Budde
2023-06-12 11:42 ` Srinivas Goud [this message]
2023-06-13 7:51 ` [PATCH 3/3] can: xilinx_can: Add debugfs support for ECC Marc Kleine-Budde
2023-06-16 11:12 ` [PATCH 0/3] can: xilinx_can: Add ECC feature support Marc Kleine-Budde
2023-06-23 7:48 ` Michal Simek
2023-06-30 8:04 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1686570177-2836108-4-git-send-email-srinivas.goud@amd.com \
--to=srinivas.goud@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gcnu.goud@gmail.com \
--cc=git@amd.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=mkl@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®