All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hao Lan <lanhao@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>
Cc: <yisen.zhuang@huawei.com>, <salil.mehta@huawei.com>,
	<edumazet@google.com>, <pabeni@redhat.com>,
	<richardcochran@gmail.com>, <shenjian15@huawei.com>,
	<netdev@vger.kernel.org>
Subject: [PATCH net-next 2/2] net: hns3: support debugfs for wake on lan
Date: Mon, 6 Feb 2023 21:49:33 +0800	[thread overview]
Message-ID: <20230206134933.32700-3-lanhao@huawei.com> (raw)
In-Reply-To: <20230206134933.32700-1-lanhao@huawei.com>

Implement debugfs for wake on lan to hns3. The debugfs
support verify the firmware wake on lan configuration.

Signed-off-by: Hao Lan <lanhao@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  1 +
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    | 10 +++
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 62 +++++++++++++++++++
 3 files changed, 73 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 312ac1cccd39..939308f8f472 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -321,6 +321,7 @@ enum hnae3_dbg_cmd {
 	HNAE3_DBG_CMD_UMV_INFO,
 	HNAE3_DBG_CMD_PAGE_POOL_INFO,
 	HNAE3_DBG_CMD_COAL_INFO,
+	HNAE3_DBG_CMD_WOL_INFO,
 	HNAE3_DBG_CMD_UNKNOWN,
 };
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 66feb23f7b7b..679a39aab801 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -357,6 +357,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
 		.buf_len = HNS3_DBG_READ_LEN_1MB,
 		.init = hns3_dbg_common_file_init,
 	},
+	{
+		.name = "wol_info",
+		.cmd = HNAE3_DBG_CMD_WOL_INFO,
+		.dentry = HNS3_DBG_DENTRY_COMMON,
+		.buf_len = HNS3_DBG_READ_LEN,
+		.init = hns3_dbg_common_file_init,
+	},
 };
 
 static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
@@ -408,6 +415,9 @@ static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
 	}, {
 		.name = "support lane num",
 		.cap_bit = HNAE3_DEV_SUPPORT_LANE_NUM_B,
+	}, {
+		.name = "support wake on lan",
+		.cap_bit = HNAE3_DEV_SUPPORT_WOL_B,
 	}
 };
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index 142415c84c6b..fdbf031bcd49 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -2394,6 +2394,64 @@ static int hclge_dbg_dump_mac_mc(struct hclge_dev *hdev, char *buf, int len)
 	return 0;
 }
 
+static void hclge_dump_wol_mode(u32 mode, char *buf, int len, int *pos)
+{
+	if (mode & HCLGE_WOL_PHY)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [p]phy\n");
+
+	if (mode & HCLGE_WOL_UNICAST)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [u]unicast\n");
+
+	if (mode & HCLGE_WOL_MULTICAST)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [m]multicast\n");
+
+	if (mode & HCLGE_WOL_BROADCAST)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [b]broadcast\n");
+
+	if (mode & HCLGE_WOL_ARP)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [a]arp\n");
+
+	if (mode & HCLGE_WOL_MAGIC)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [g]magic\n");
+
+	if (mode & HCLGE_WOL_MAGICSECURED)
+		*pos += scnprintf(buf + *pos, len - *pos,
+				 "  [s]magic secured\n");
+
+	if (mode & HCLGE_WOL_FILTER)
+		*pos += scnprintf(buf + *pos, len - *pos, "  [f]filter\n");
+}
+
+static int hclge_dbg_dump_wol_info(struct hclge_dev *hdev, char *buf, int len)
+{
+	u32 wol_supported;
+	int pos = 0;
+	u32 mode;
+
+	if (!hnae3_ae_dev_wol_supported(hdev->ae_dev)) {
+		pos += scnprintf(buf + pos, len - pos,
+				 "wake-on-lan is unsupported\n");
+		return 0;
+	}
+
+	pos += scnprintf(buf + pos, len - pos, "wake-on-lan mode:\n");
+	pos += scnprintf(buf + pos, len - pos, " supported:\n");
+	if (hclge_get_wol_supported_mode(hdev, &wol_supported))
+		return -EINVAL;
+
+	hclge_dump_wol_mode(wol_supported, buf, len, &pos);
+
+	pos += scnprintf(buf + pos, len - pos, " current:\n");
+	if (hclge_get_wol_cfg(hdev, &mode))
+		return -EINVAL;
+	if (mode)
+		hclge_dump_wol_mode(mode, buf, len, &pos);
+	else
+		pos += scnprintf(buf + pos, len - pos, "  [d]disabled\n");
+
+	return 0;
+}
+
 static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
 	{
 		.cmd = HNAE3_DBG_CMD_TM_NODES,
@@ -2543,6 +2601,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
 		.cmd = HNAE3_DBG_CMD_UMV_INFO,
 		.dbg_dump = hclge_dbg_dump_umv_info,
 	},
+	{
+		.cmd = HNAE3_DBG_CMD_WOL_INFO,
+		.dbg_dump = hclge_dbg_dump_wol_info,
+	},
 };
 
 int hclge_dbg_read_cmd(struct hnae3_handle *handle, enum hnae3_dbg_cmd cmd,
-- 
2.30.0


  parent reply	other threads:[~2023-02-06 13:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 13:49 [PATCH net-next 0/2] net: hns3: support wake on lan for hns3 Hao Lan
2023-02-06 13:49 ` [PATCH net-next 1/2] net: hns3: support wake on lan configuration and query Hao Lan
2023-02-06 13:49 ` Hao Lan [this message]
2023-02-06 13:53 ` [PATCH net-next 0/2] net: hns3: support wake on lan for hns3 Hao Lan
  -- strict thread matches above, loose matches on Subject: below --
2023-01-04  1:34 Hao Lan
2023-01-04  1:34 ` [PATCH net-next 2/2] net: hns3: support debugfs for wake on lan Hao Lan
2023-01-04  2:12   ` Andrew Lunn

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=20230206134933.32700-3-lanhao@huawei.com \
    --to=lanhao@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=salil.mehta@huawei.com \
    --cc=shenjian15@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 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.