]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: hns3: device specifications add number of mac statistics
authorGuangbin Huang <huangguangbin2@huawei.com>
Sun, 24 Oct 2021 09:41:10 +0000 (17:41 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Oct 2021 13:00:59 +0000 (14:00 +0100)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index 07c83af3683105c561783d04378870bdee519052..3f7a9a4c59d566a9f368c47348aa3994bf254585 100644 (file)
@@ -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 {
index 578d693b23c258d2dfb1b4780bbad4ae17b560bb..1a1bebd453d33c40fed265143a7ee5c990568f2b 100644 (file)
@@ -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)
index a4e3349d21577d582c7984eedd884cf071eda8ab..7c807abe968ad714780f7d3bc65f9da76c41ef4b 100644 (file)
@@ -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, &reg_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, &reg_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.
         */