Commit c5f65480 authored by Jian Shen's avatar Jian Shen Committed by David S. Miller

net: hns3: Modify the update period of packet statistics

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: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7ea5cbdc
...@@ -1126,6 +1126,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) ...@@ -1126,6 +1126,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
int queue_num = priv->ae_handle->kinfo.num_tqps; int queue_num = priv->ae_handle->kinfo.num_tqps;
struct hnae3_handle *handle = priv->ae_handle;
struct hns3_enet_ring *ring; struct hns3_enet_ring *ring;
unsigned int start; unsigned int start;
unsigned int idx; unsigned int idx;
...@@ -1134,6 +1135,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) ...@@ -1134,6 +1135,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
u64 tx_pkts = 0; u64 tx_pkts = 0;
u64 rx_pkts = 0; u64 rx_pkts = 0;
handle->ae_algo->ops->update_stats(handle, &netdev->stats);
for (idx = 0; idx < queue_num; idx++) { for (idx = 0; idx < queue_num; idx++) {
/* fetch the tx stats */ /* fetch the tx stats */
ring = priv->ring_data[idx].ring; ring = priv->ring_data[idx].ring;
......
...@@ -698,6 +698,9 @@ static void hclge_update_stats(struct hnae3_handle *handle, ...@@ -698,6 +698,9 @@ static void hclge_update_stats(struct hnae3_handle *handle,
struct hclge_hw_stats *hw_stats = &hdev->hw_stats; struct hclge_hw_stats *hw_stats = &hdev->hw_stats;
int status; int status;
if (test_and_set_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state))
return;
status = hclge_mac_update_stats(hdev); status = hclge_mac_update_stats(hdev);
if (status) if (status)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
...@@ -723,6 +726,8 @@ static void hclge_update_stats(struct hnae3_handle *handle, ...@@ -723,6 +726,8 @@ static void hclge_update_stats(struct hnae3_handle *handle,
status); status);
hclge_update_netstat(hw_stats, net_stats); 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) 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) ...@@ -2380,6 +2385,7 @@ static void hclge_service_timer(struct timer_list *t)
struct hclge_dev *hdev = from_timer(hdev, t, service_timer); struct hclge_dev *hdev = from_timer(hdev, t, service_timer);
mod_timer(&hdev->service_timer, jiffies + HZ); mod_timer(&hdev->service_timer, jiffies + HZ);
hdev->hw_stats.stats_timer++;
hclge_task_schedule(hdev); hclge_task_schedule(hdev);
} }
...@@ -2779,9 +2785,13 @@ static void hclge_service_task(struct work_struct *work) ...@@ -2779,9 +2785,13 @@ static void hclge_service_task(struct work_struct *work)
struct hclge_dev *hdev = struct hclge_dev *hdev =
container_of(work, struct hclge_dev, service_task); 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_speed_duplex(hdev);
hclge_update_link_status(hdev); hclge_update_link_status(hdev);
hclge_update_stats_for_all(hdev);
hclge_service_complete(hdev); hclge_service_complete(hdev);
} }
......
...@@ -112,6 +112,7 @@ enum HCLGE_DEV_STATE { ...@@ -112,6 +112,7 @@ enum HCLGE_DEV_STATE {
HCLGE_STATE_RST_HANDLING, HCLGE_STATE_RST_HANDLING,
HCLGE_STATE_MBX_SERVICE_SCHED, HCLGE_STATE_MBX_SERVICE_SCHED,
HCLGE_STATE_MBX_HANDLING, HCLGE_STATE_MBX_HANDLING,
HCLGE_STATE_STATISTICS_UPDATING,
HCLGE_STATE_MAX HCLGE_STATE_MAX
}; };
...@@ -422,10 +423,12 @@ struct hclge_mac_stats { ...@@ -422,10 +423,12 @@ struct hclge_mac_stats {
u64 mac_rx_send_app_bad_pkt_num; u64 mac_rx_send_app_bad_pkt_num;
}; };
#define HCLGE_STATS_TIMER_INTERVAL (60 * 5)
struct hclge_hw_stats { struct hclge_hw_stats {
struct hclge_mac_stats mac_stats; struct hclge_mac_stats mac_stats;
struct hclge_64_bit_stats all_64_bit_stats; struct hclge_64_bit_stats all_64_bit_stats;
struct hclge_32_bit_stats all_32_bit_stats; struct hclge_32_bit_stats all_32_bit_stats;
u32 stats_timer;
}; };
struct hclge_vlan_type_cfg { struct hclge_vlan_type_cfg {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment