linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huazhong Tan <tanhuazhong@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
	<linuxarm@huawei.com>, <kuba@kernel.org>,
	Huazhong Tan <tanhuazhong@huawei.com>
Subject: [PATCH V2 net-next 11/11] net: hns3: add debugfs support for interrupt coalesce
Date: Mon, 9 Nov 2020 11:22:39 +0800	[thread overview]
Message-ID: <1604892159-19990-12-git-send-email-tanhuazhong@huawei.com> (raw)
In-Reply-To: <1604892159-19990-1-git-send-email-tanhuazhong@huawei.com>

Since user may need to check the current configuration of the
interrupt coalesce, so add debugfs support for query this info,
which includes DIM profile, coalesce configuration of both software
and hardware.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 126 +++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index a5ebca8..26fa69a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -12,6 +12,93 @@
 
 static struct dentry *hns3_dbgfs_root;
 
+static ssize_t hns3_dbg_coal_write(struct file *filp, const char __user *buffer,
+				   size_t count, loff_t *ppos)
+{
+	struct hnae3_handle *h = filp->private_data;
+	struct hns3_nic_priv *priv  = h->priv;
+	struct hns3_enet_tqp_vector *tqp_vector;
+	struct hns3_enet_coalesce *coal;
+	u8 __iomem *base_addr;
+	int uncopied_bytes;
+	unsigned int idx;
+	struct dim *dim;
+	char *cmd_buf;
+
+	if (*ppos != 0)
+		return 0;
+
+	if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
+		dev_err(&h->pdev->dev, "device is not initialized\n");
+		return -EFAULT;
+	}
+
+	cmd_buf = kzalloc(count + 1, GFP_KERNEL);
+	if (!cmd_buf)
+		return -ENOMEM;
+
+	uncopied_bytes = copy_from_user(cmd_buf, buffer, count);
+	if (uncopied_bytes) {
+		kfree(cmd_buf);
+		return -EFAULT;
+	}
+
+	cmd_buf[count] = '\0';
+
+	if (kstrtouint(cmd_buf, 0, &idx))
+		idx = 0;
+
+	if (idx >= priv->vector_num) {
+		dev_err(&h->pdev->dev,
+			"vector index(%u) is out of range(0-%u)\n", idx,
+			priv->vector_num - 1);
+		kfree(cmd_buf);
+		return -EINVAL;
+	}
+
+	tqp_vector = &priv->tqp_vector[idx];
+	coal = &tqp_vector->tx_group.coal;
+	dim = &tqp_vector->tx_group.dim;
+	base_addr = tqp_vector->mask_addr;
+
+	dev_info(&h->pdev->dev, "vector[%u] interrupt coalesce info:\n", idx);
+	dev_info(&h->pdev->dev,
+		 "TX DIM info state = %d profile_ix = %d mode = %d tune_state = %d steps_right = %d steps_left = %d tired = %d\n",
+		 dim->state, dim->profile_ix, dim->mode, dim->tune_state,
+		 dim->steps_right, dim->steps_left, dim->tired);
+
+	dev_info(&h->pdev->dev, "TX GL info sw_gl = %u, hw_gl = %u\n",
+		 coal->int_gl,
+		 readl(base_addr + HNS3_VECTOR_GL1_OFFSET));
+
+	if (coal->ql_enable)
+		dev_info(&h->pdev->dev, "TX QL info sw_ql = %u, hw_ql = %u\n",
+			 coal->int_ql,
+			 readl(base_addr + HNS3_VECTOR_TX_QL_OFFSET));
+
+	coal = &tqp_vector->rx_group.coal;
+	dim = &tqp_vector->rx_group.dim;
+
+	dev_info(&h->pdev->dev,
+		 "RX dim_info state = %d profile_ix = %d mode = %d tune_state = %d steps_right = %d steps_left = %d tired = %d\n",
+		 dim->state, dim->profile_ix, dim->mode, dim->tune_state,
+		 dim->steps_right, dim->steps_left, dim->tired);
+
+	dev_info(&h->pdev->dev, "RX GL info sw_gl = %u, hw_gl = %u\n",
+		 coal->int_gl,
+		 readl(base_addr + HNS3_VECTOR_GL0_OFFSET));
+
+	if (coal->ql_enable)
+		dev_info(&h->pdev->dev, "RX QL info sw_ql = %u, hw_ql = %u\n",
+			 coal->int_ql,
+			 readl(base_addr + HNS3_VECTOR_RX_QL_OFFSET));
+
+	kfree(cmd_buf);
+	cmd_buf = NULL;
+
+	return count;
+}
+
 static int hns3_dbg_queue_info(struct hnae3_handle *h,
 			       const char *cmd_buf)
 {
@@ -352,6 +439,35 @@ static void hns3_dbg_dev_specs(struct hnae3_handle *h)
 	dev_info(priv->dev, "MAX INT GL: %u\n", dev_specs->max_int_gl);
 }
 
+static ssize_t hns3_dbg_coal_read(struct file *filp, char __user *buffer,
+				  size_t count, loff_t *ppos)
+{
+	int uncopy_bytes;
+	char *buf;
+	int len;
+
+	if (*ppos != 0)
+		return 0;
+
+	if (count < HNS3_DBG_READ_LEN)
+		return -ENOSPC;
+
+	buf = kzalloc(HNS3_DBG_READ_LEN, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
+			"Please echo index to coal");
+	uncopy_bytes = copy_to_user(buffer, buf, len);
+
+	kfree(buf);
+
+	if (uncopy_bytes)
+		return -EFAULT;
+
+	return (*ppos = len);
+}
+
 static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer,
 				 size_t count, loff_t *ppos)
 {
@@ -452,6 +568,13 @@ static const struct file_operations hns3_dbg_cmd_fops = {
 	.write = hns3_dbg_cmd_write,
 };
 
+static const struct file_operations hns3_dbg_coal_fops = {
+	.owner = THIS_MODULE,
+	.open  = simple_open,
+	.read  = hns3_dbg_coal_read,
+	.write = hns3_dbg_coal_write,
+};
+
 void hns3_dbg_init(struct hnae3_handle *handle)
 {
 	const char *name = pci_name(handle->pdev);
@@ -460,6 +583,9 @@ void hns3_dbg_init(struct hnae3_handle *handle)
 
 	debugfs_create_file("cmd", 0600, handle->hnae3_dbgfs, handle,
 			    &hns3_dbg_cmd_fops);
+
+	debugfs_create_file("coal", 0600, handle->hnae3_dbgfs, handle,
+			    &hns3_dbg_coal_fops);
 }
 
 void hns3_dbg_uninit(struct hnae3_handle *handle)
-- 
2.7.4


  parent reply	other threads:[~2020-11-09  3:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09  3:22 [PATCH V2 net-next 00/11] net: hns3: updates for -next Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 01/11] net: hns3: add support for configuring interrupt quantity limiting Huazhong Tan
2020-11-11  1:13   ` Jakub Kicinski
2020-11-11  1:15     ` tanhuazhong
2020-11-09  3:22 ` [PATCH V2 net-next 02/11] net: hns3: add support for querying maximum value of GL Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 03/11] net: hns3: add support for 1us unit GL configuration Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 04/11] net: hns3: rename gl_adapt_enable in struct hns3_enet_coalesce Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 05/11] net: hns3: add support for dynamic interrupt moderation Huazhong Tan
2020-11-11  1:20   ` Jakub Kicinski
2020-11-11  2:31     ` tanhuazhong
2020-11-09  3:22 ` [PATCH V2 net-next 06/11] net: hns3: add ethtool priv-flag for DIM Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 07/11] net: hns3: add hns3_state_init() to do state initialization Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 08/11] net: hns3: add a check for ethtool priv-flag interface Huazhong Tan
2020-11-09  3:22 ` [PATCH V2 net-next 09/11] net: hns3: add support for EQ/CQ mode configuration Huazhong Tan
2020-11-11  1:25   ` Jakub Kicinski
2020-11-11  3:03     ` tanhuazhong
2020-11-09  3:22 ` [PATCH V2 net-next 10/11] net: hns3: add ethtool priv-flag for EQ/CQ Huazhong Tan
2020-11-09  3:22 ` Huazhong Tan [this message]
2020-11-11  1:28   ` [PATCH V2 net-next 11/11] net: hns3: add debugfs support for interrupt coalesce Jakub Kicinski
2020-11-11  3:16     ` tanhuazhong
2020-11-11 16:15       ` Jakub Kicinski
2020-11-12  0:48         ` tanhuazhong

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=1604892159-19990-12-git-send-email-tanhuazhong@huawei.com \
    --to=tanhuazhong@huawei.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@huawei.com \
    --cc=yisen.zhuang@huawei.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;
as well as URLs for NNTP newsgroup(s).