From: Guangbin Huang <huangguangbin2@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <wangjie125@huawei.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lipeng321@huawei.com>, <huangguangbin2@huawei.com>,
<chenhao288@hisilicon.com>
Subject: [PATCH net-next 3/8] net: hns3: device specifications add number of mac statistics
Date: Sun, 24 Oct 2021 17:41:10 +0800 [thread overview]
Message-ID: <20211024094115.42158-4-huangguangbin2@huawei.com> (raw)
In-Reply-To: <20211024094115.42158-1-huangguangbin2@huawei.com>
Currently, driver queries number of mac statistics before querying mac
statistics. As the number of mac statistics is a fixed value in firmware,
it is redundant to query this number everytime before querying mac
statistics, it can just be queried once in initialization process and
saved in device specifications.
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 +
.../ethernet/hisilicon/hns3/hns3_debugfs.c | 2 ++
.../hisilicon/hns3/hns3pf/hclge_main.c | 34 +++++++++++++------
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 07c83af36831..3f7a9a4c59d5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -349,6 +349,7 @@ struct hnae3_dev_specs {
u16 max_qset_num;
u16 umv_size;
u16 mc_mac_size;
+ u32 mac_stats_num;
};
struct hnae3_client_ops {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 578d693b23c2..1a1bebd453d3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -1050,6 +1050,8 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
dev_specs->umv_size);
*pos += scnprintf(buf + *pos, len - *pos, "mc mac size: %u\n",
dev_specs->mc_mac_size);
+ *pos += scnprintf(buf + *pos, len - *pos, "MAC statistics number: %u\n",
+ dev_specs->mac_stats_num);
}
static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index a4e3349d2157..7c807abe968a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -480,10 +480,11 @@ static int hclge_mac_update_stats_defective(struct hclge_dev *hdev)
return 0;
}
-static int hclge_mac_update_stats_complete(struct hclge_dev *hdev, u32 reg_num)
+static int hclge_mac_update_stats_complete(struct hclge_dev *hdev)
{
#define HCLGE_REG_NUM_PER_DESC 4
+ u32 reg_num = hdev->ae_dev->dev_specs.mac_stats_num;
u64 *data = (u64 *)(&hdev->mac_stats);
struct hclge_desc *desc;
__le64 *desc_data;
@@ -552,17 +553,11 @@ static int hclge_mac_query_reg_num(struct hclge_dev *hdev, u32 *reg_num)
static int hclge_mac_update_stats(struct hclge_dev *hdev)
{
- u32 reg_num;
- int ret;
-
- ret = hclge_mac_query_reg_num(hdev, ®_num);
/* The firmware supports the new statistics acquisition method */
- if (!ret)
- ret = hclge_mac_update_stats_complete(hdev, reg_num);
- else if (ret == -EOPNOTSUPP)
- ret = hclge_mac_update_stats_defective(hdev);
-
- return ret;
+ if (hdev->ae_dev->dev_specs.mac_stats_num)
+ return hclge_mac_update_stats_complete(hdev);
+ else
+ return hclge_mac_update_stats_defective(hdev);
}
static int hclge_tqps_update_stats(struct hnae3_handle *handle)
@@ -1465,12 +1460,29 @@ static void hclge_check_dev_specs(struct hclge_dev *hdev)
dev_specs->umv_size = HCLGE_DEFAULT_UMV_SPACE_PER_PF;
}
+static int hclge_query_mac_stats_num(struct hclge_dev *hdev)
+{
+ u32 reg_num = 0;
+ int ret;
+
+ ret = hclge_mac_query_reg_num(hdev, ®_num);
+ if (ret && ret != -EOPNOTSUPP)
+ return ret;
+
+ hdev->ae_dev->dev_specs.mac_stats_num = reg_num;
+ return 0;
+}
+
static int hclge_query_dev_specs(struct hclge_dev *hdev)
{
struct hclge_desc desc[HCLGE_QUERY_DEV_SPECS_BD_NUM];
int ret;
int i;
+ ret = hclge_query_mac_stats_num(hdev);
+ if (ret)
+ return ret;
+
/* set default specifications as devices lower than version V3 do not
* support querying specifications from firmware.
*/
--
2.33.0
next prev parent reply other threads:[~2021-10-24 9:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-24 9:41 [PATCH V2 net-next 0/8] net: hns3: updates for -next Guangbin Huang
2021-10-24 9:41 ` [PATCH net-next 1/8] net: hns3: add debugfs support for interrupt coalesce Guangbin Huang
2021-10-24 9:41 ` [PATCH net-next 2/8] net: hns3: modify mac statistics update process for compatibility Guangbin Huang
2021-10-24 9:41 ` Guangbin Huang [this message]
2021-10-24 9:41 ` [PATCH net-next 4/8] net: hns3: add support pause/pfc durations for mac statistics Guangbin Huang
2021-10-24 9:41 ` [PATCH net-next 5/8] net: hns3: modify functions of converting speed ability to ethtool link mode Guangbin Huang
2021-10-24 9:41 ` [PATCH net-next 6/8] net: hns3: add update ethtool advertised link modes for FIBRE port when autoneg off Guangbin Huang
2021-10-24 9:41 ` [PATCH net-next 7/8] net: hns3: add new ras error type for roce Guangbin Huang
2021-10-24 9:41 ` [PATCH net-next 8/8] net: hns3: add error recovery module and type for himac Guangbin Huang
2021-10-25 13:10 ` [PATCH V2 net-next 0/8] net: hns3: updates for -next patchwork-bot+netdevbpf
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=20211024094115.42158-4-huangguangbin2@huawei.com \
--to=huangguangbin2@huawei.com \
--cc=chenhao288@hisilicon.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lipeng321@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=wangjie125@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
all inboxes | Powered by JetHome®