net: hns3: add reset statistics for VF
authorHuazhong Tan <tanhuazhong@huawei.com>
Fri, 19 Apr 2019 03:05:37 +0000 (11:05 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 20 Apr 2019 01:43:15 +0000 (18:43 -0700)
This patch adds some statistics for VF reset.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h

index 2e277c91a106b50a5a9fa7052b30bf031cdd67b6..ff2cdf91a2554f2b8fabee4317b69cca86754f06 100644 (file)
@@ -1415,9 +1415,11 @@ static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev)
        case HNAE3_VF_FUNC_RESET:
                ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_RESET, 0, NULL,
                                           0, true, NULL, sizeof(u8));
+               hdev->rst_stats.vf_func_rst_cnt++;
                break;
        case HNAE3_FLR_RESET:
                set_bit(HNAE3_FLR_DOWN, &hdev->flr_state);
+               hdev->rst_stats.flr_rst_cnt++;
                break;
        default:
                break;
@@ -1440,7 +1442,7 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
         * know if device is undergoing reset
         */
        ae_dev->reset_type = hdev->reset_type;
-       hdev->reset_count++;
+       hdev->rst_stats.rst_cnt++;
        rtnl_lock();
 
        /* bring down the nic to stop any ongoing TX/RX */
@@ -1466,6 +1468,8 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
                goto err_reset;
        }
 
+       hdev->rst_stats.hw_rst_done_cnt++;
+
        rtnl_lock();
 
        /* now, re-initialize the nic client and ae device*/
@@ -1484,6 +1488,7 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
 
        hdev->last_reset_time = jiffies;
        ae_dev->reset_type = HNAE3_NONE_RESET;
+       hdev->rst_stats.rst_done_cnt++;
 
        return ret;
 err_reset_lock:
@@ -1803,6 +1808,7 @@ static enum hclgevf_evt_cause hclgevf_check_evt_cause(struct hclgevf_dev *hdev,
                set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state);
                cmdq_src_reg &= ~BIT(HCLGEVF_VECTOR0_RST_INT_B);
                *clearval = cmdq_src_reg;
+               hdev->rst_stats.vf_rst_cnt++;
                return HCLGEVF_VECTOR0_EVENT_RST;
        }
 
@@ -2737,7 +2743,7 @@ static unsigned long hclgevf_ae_dev_reset_cnt(struct hnae3_handle *handle)
 {
        struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
 
-       return hdev->reset_count;
+       return hdev->rst_stats.hw_rst_done_cnt;
 }
 
 static void hclgevf_get_link_mode(struct hnae3_handle *handle,
index 49e5bec53d45624d8afae0475d4f1737f02e59b4..d39c0323ca99f922ca6b071c65a4327f82b65fd6 100644 (file)
@@ -210,6 +210,15 @@ struct hclgevf_misc_vector {
        int vector_irq;
 };
 
+struct hclgevf_rst_stats {
+       u32 rst_cnt;                    /* the number of reset */
+       u32 vf_func_rst_cnt;            /* the number of VF function reset */
+       u32 flr_rst_cnt;                /* the number of FLR */
+       u32 vf_rst_cnt;                 /* the number of VF reset */
+       u32 rst_done_cnt;               /* the number of reset completed */
+       u32 hw_rst_done_cnt;            /* the number of HW reset completed */
+};
+
 struct hclgevf_dev {
        struct pci_dev *pdev;
        struct hnae3_ae_dev *ae_dev;
@@ -227,7 +236,7 @@ struct hclgevf_dev {
 #define HCLGEVF_RESET_REQUESTED                0
 #define HCLGEVF_RESET_PENDING          1
        unsigned long reset_state;      /* requested, pending */
-       unsigned long reset_count;      /* the number of reset has been done */
+       struct hclgevf_rst_stats rst_stats;
        u32 reset_attempts;
 
        u32 fw_version;