]> git.droids-corp.org - dpdk.git/commitdiff
net/hns3: skip VF register access when PF in FLR
authorHongbo Zheng <zhenghongbo3@huawei.com>
Tue, 22 Sep 2020 12:03:18 +0000 (20:03 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:10 +0000 (19:19 +0200)
According to the protocol of PCIe, FLR to a PF device resets the PF state
as well as the SR-IOV extended capability including VF Enable which means
that VFs no longer exist.

When PF device is in FLR reset stage, at this time, the register state
of VF device is not reliable, so VF device's register state detection
is not carried out in PF FLR.

In this case, we just ignore the register states to avoid accessing
nonexistent register and return false in the internal function named
hns3vf_is_reset_pending to indicate that there are no other reset states
that need to be processed by PMD driver.

Fixes: 2790c6464725 ("net/hns3: support device reset")
Cc: stable@dpdk.org
Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
drivers/net/hns3/hns3_ethdev.h
drivers/net/hns3/hns3_ethdev_vf.c

index f170df91764f03c03b80c3a89e307e47f731bd4f..3f3f973c72ff533cc499d5da18248e713dba39ba 100644 (file)
@@ -275,6 +275,13 @@ enum hns3_reset_level {
         * Kernel PF driver use mailbox to inform DPDK VF to do reset, the value
         * of the reset level and the one defined in kernel driver should be
         * same.
+        *
+        * According to the protocol of PCIe, FLR to a PF resets the PF state as
+        * well as the SR-IOV extended capability including VF Enable which
+        * means that VFs no longer exist.
+        *
+        * In PF FLR, the register state of VF is not reliable, VF's driver
+        * should not access the registers of the VF device.
         */
        HNS3_VF_FULL_RESET = 3,
        HNS3_FLR_RESET,     /* A VF perform FLR reset */
index 565cf60e76bb8aadf4be9bb950fb94b6ba4eaf4d..cb2747b13294413604094a4ab77962a018db41b0 100644 (file)
@@ -2191,6 +2191,21 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns)
        struct hns3_hw *hw = &hns->hw;
        enum hns3_reset_level reset;
 
+       /*
+        * According to the protocol of PCIe, FLR to a PF device resets the PF
+        * state as well as the SR-IOV extended capability including VF Enable
+        * which means that VFs no longer exist.
+        *
+        * HNS3_VF_FULL_RESET means PF device is in FLR reset. when PF device
+        * is in FLR stage, the register state of VF device is not reliable,
+        * so register states detection can not be carried out. In this case,
+        * we just ignore the register states and return false to indicate that
+        * there are no other reset states that need to be processed by driver.
+        */
+       if (hw->reset.level == HNS3_VF_FULL_RESET)
+               return false;
+
+       /* Check the registers to confirm whether there is reset pending */
        hns3vf_check_event_cause(hns, NULL);
        reset = hns3vf_get_reset_level(hw, &hw->reset.pending);
        if (hw->reset.level != HNS3_NONE_RESET && hw->reset.level < reset) {