net/i40e/base: add new link speed constants
[dpdk.git] / drivers / net / hns3 / hns3_cmd.c
index 706b910..65a5af8 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_regs.h"
+#include "hns3_intr.h"
 #include "hns3_logs.h"
 
 #define hns3_is_csq(ring) ((ring)->flag & HNS3_TYPE_CSQ)
@@ -214,9 +215,13 @@ hns3_cmd_csq_clean(struct hns3_hw *hw)
        head = hns3_read_dev(hw, HNS3_CMDQ_TX_HEAD_REG);
 
        if (!is_valid_csq_clean_head(csq, head)) {
+               struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
                hns3_err(hw, "wrong cmd head (%u, %u-%u)", head,
                            csq->next_to_use, csq->next_to_clean);
                rte_atomic16_set(&hw->reset.disable_cmd, 1);
+
+               hns3_schedule_delayed_reset(hns);
+
                return -EIO;
        }
 
@@ -317,6 +322,7 @@ hns3_cmd_get_hardware_reply(struct hns3_hw *hw,
 
 static int hns3_cmd_poll_reply(struct hns3_hw *hw)
 {
+       struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
        uint32_t timeout = 0;
 
        do {
@@ -329,11 +335,16 @@ static int hns3_cmd_poll_reply(struct hns3_hw *hw)
                        return -EBUSY;
                }
 
+               if (is_reset_pending(hns)) {
+                       hns3_err(hw, "Don't wait for reply because of reset pending");
+                       return -EIO;
+               }
+
                rte_delay_us(1);
                timeout++;
        } while (timeout < hw->cmq.tx_timeout);
        hns3_err(hw, "Wait for reply timeout");
-       return -EBADE;
+       return -ETIME;
 }
 
 /*
@@ -484,6 +495,15 @@ hns3_cmd_init(struct hns3_hw *hw)
        rte_spinlock_unlock(&hw->cmq.crq.lock);
        rte_spinlock_unlock(&hw->cmq.csq.lock);
 
+       /*
+        * Check if there is new reset pending, because the higher level
+        * reset may happen when lower level reset is being processed.
+        */
+       if (is_reset_pending(HNS3_DEV_HW_TO_ADAPTER(hw))) {
+               PMD_INIT_LOG(ERR, "New reset pending, keep disable cmd");
+               ret = -EBUSY;
+               goto err_cmd_init;
+       }
        rte_atomic16_clear(&hw->reset.disable_cmd);
 
        ret = hns3_cmd_query_firmware_version(hw, &hw->fw_version);