linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Li <lipeng321@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linuxarm@huawei.com>, <salil.mehta@huawei.com>,
	<lipeng321@huawei.com>
Subject: [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics
Date: Fri, 5 Jan 2018 18:18:10 +0800	[thread overview]
Message-ID: <1515147504-86802-7-git-send-email-lipeng321@huawei.com> (raw)
In-Reply-To: <1515147504-86802-1-git-send-email-lipeng321@huawei.com>

From: Jian Shen <shenjian15@huawei.com>

It takes more than 200 query response messages between
driver and IMP, while updating the packet statistics.
It's too heavy for IMP to update it per second.

Extend the update period of packet statistics data from
1 second to 300 seconds(if too long, the statistics may
overflow).

As a result, we need to update it while querying with
ifconfig tool to keep the statistics data fresh.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c         |  3 +++
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 12 +++++++++++-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h |  3 +++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 565d85d..79c5daa 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev,
 {
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
 	int queue_num = priv->ae_handle->kinfo.num_tqps;
+	struct hnae3_handle *handle = priv->ae_handle;
 	struct hns3_enet_ring *ring;
 	unsigned int start;
 	unsigned int idx;
@@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
 	u64 tx_pkts = 0;
 	u64 rx_pkts = 0;
 
+	handle->ae_algo->ops->update_stats(handle, &netdev->stats);
+
 	for (idx = 0; idx < queue_num; idx++) {
 		/* fetch the tx stats */
 		ring = priv->ring_data[idx].ring;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 2cca37c..20ec791 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -698,6 +698,9 @@ static void hclge_update_stats(struct hnae3_handle *handle,
 	struct hclge_hw_stats *hw_stats = &hdev->hw_stats;
 	int status;
 
+	if (test_and_set_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state))
+		return;
+
 	status = hclge_mac_update_stats(hdev);
 	if (status)
 		dev_err(&hdev->pdev->dev,
@@ -723,6 +726,8 @@ static void hclge_update_stats(struct hnae3_handle *handle,
 			status);
 
 	hclge_update_netstat(hw_stats, net_stats);
+
+	clear_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state);
 }
 
 static int hclge_get_sset_count(struct hnae3_handle *handle, int stringset)
@@ -2380,6 +2385,7 @@ static void hclge_service_timer(struct timer_list *t)
 	struct hclge_dev *hdev = from_timer(hdev, t, service_timer);
 
 	mod_timer(&hdev->service_timer, jiffies + HZ);
+	hdev->hw_stats.stats_timer++;
 	hclge_task_schedule(hdev);
 }
 
@@ -2779,9 +2785,13 @@ static void hclge_service_task(struct work_struct *work)
 	struct hclge_dev *hdev =
 		container_of(work, struct hclge_dev, service_task);
 
+	if (hdev->hw_stats.stats_timer >= HCLGE_STATS_TIMER_INTERVAL) {
+		hclge_update_stats_for_all(hdev);
+		hdev->hw_stats.stats_timer = 0;
+	}
+
 	hclge_update_speed_duplex(hdev);
 	hclge_update_link_status(hdev);
-	hclge_update_stats_for_all(hdev);
 	hclge_service_complete(hdev);
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 15ca95f..50ae13a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -112,6 +112,7 @@ enum HCLGE_DEV_STATE {
 	HCLGE_STATE_RST_HANDLING,
 	HCLGE_STATE_MBX_SERVICE_SCHED,
 	HCLGE_STATE_MBX_HANDLING,
+	HCLGE_STATE_STATISTICS_UPDATING,
 	HCLGE_STATE_MAX
 };
 
@@ -422,10 +423,12 @@ struct hclge_mac_stats {
 	u64 mac_rx_send_app_bad_pkt_num;
 };
 
+#define HCLGE_STATS_TIMER_INTERVAL	(60 * 5)
 struct hclge_hw_stats {
 	struct hclge_mac_stats      mac_stats;
 	struct hclge_64_bit_stats   all_64_bit_stats;
 	struct hclge_32_bit_stats   all_32_bit_stats;
+	u32 stats_timer;
 };
 
 struct hclge_vlan_type_cfg {
-- 
1.9.1

  parent reply	other threads:[~2018-01-05  9:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
2018-01-05 10:18 ` [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter Peng Li
2018-01-05 10:18 ` [PATCH net-next 02/20] net: hns3: Disable VFs change rxvlan offload status Peng Li
2018-01-05 10:18 ` [PATCH net-next 03/20] net: hns3: Unify the strings display of packet statistics Peng Li
2018-01-05 10:18 ` [PATCH net-next 04/20] net: hns3: Fix spelling errors Peng Li
2018-01-05 10:18 ` [PATCH net-next 05/20] net: hns3: Remove repeat statistic of rx_errors Peng Li
2018-01-05 10:18 ` Peng Li [this message]
2018-01-05 14:54   ` [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics Andrew Lunn
2018-01-06  6:23     ` lipeng (Y)
2018-01-06 15:49       ` Andrew Lunn
2018-01-05 10:18 ` [PATCH net-next 07/20] net: hns3: Mask the packet statistics query when NIC is down Peng Li
2018-01-05 10:18 ` [PATCH net-next 08/20] net: hns3: Fix an error of total drop packet statistics Peng Li
2018-01-05 10:18 ` [PATCH net-next 09/20] net: hns3: Fix a loop index error of tqp statistics query Peng Li
2018-01-05 10:18 ` [PATCH net-next 10/20] net: hns3: Fix an error macro definition of HNS3_TQP_STAT Peng Li
2018-01-05 10:18 ` [PATCH net-next 11/20] net: hns3: Remove a useless member of struct hns3_stats Peng Li
2018-01-05 10:18 ` [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Peng Li
2018-01-08 20:04   ` Jakub Kicinski
2018-01-09  1:39     ` David Miller
2018-01-09  1:46       ` Jakub Kicinski
2018-01-09  1:50         ` Jakub Kicinski
2018-01-09  1:54           ` David Miller
2018-01-09  2:48             ` lipeng (Y)
2018-01-09  3:06               ` David Miller
2018-01-09  3:27                 ` lipeng (Y)
2018-01-05 10:18 ` [PATCH net-next 13/20] net: hns3: Fix a response data read error of tqp statistics query Peng Li
2018-01-05 10:18 ` [PATCH net-next 14/20] net: hns3: fix for updating fc_mode_last_time Peng Li
2018-01-05 10:18 ` [PATCH net-next 15/20] net: hns3: fix for setting MTU Peng Li
2018-01-05 10:18 ` [PATCH net-next 16/20] net: hns3: fix for changing MTU Peng Li
2018-01-05 10:18 ` [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware Peng Li
2018-01-05 10:18 ` [PATCH net-next 18/20] net: hns3: fix for not setting pause parameters Peng Li
2018-01-05 10:18 ` [PATCH net-next 19/20] net: hns3: remove redundant semicolon Peng Li
2018-01-05 10:18 ` [PATCH net-next 20/20] net: hns3: Add more packet size statisctics Peng Li
2018-01-08 19:08 ` [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver David Miller

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=1515147504-86802-7-git-send-email-lipeng321@huawei.com \
    --to=lipeng321@huawei.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@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).