Skip to content

Commit

Permalink
net/hns3: support device reset
Browse files Browse the repository at this point in the history
This patch adds reset related process for hns3 PMD driver.
The following three scenarios will trigger the reset process,
and the driver settings will be restored after the reset is
successful:
1. Receive a reset interrupt
2. PF receives a hardware error interrupt
3. VF is notified by PF to reset

Signed-off-by: Chunsong Feng <fengchunsong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Signed-off-by: Hao Chen <chenhao164@huawei.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
xavierhw authored and Ferruh Yigit committed Oct 7, 2019
1 parent 8839c5e commit 2790c64
Show file tree
Hide file tree
Showing 8 changed files with 1,582 additions and 21 deletions.
35 changes: 35 additions & 0 deletions drivers/net/hns3/hns3_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -214,9 +215,28 @@ 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);
uint32_t global;
uint32_t fun_rst;
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);
if (hns->is_vf) {
global = hns3_read_dev(hw, HNS3_VF_RST_ING);
fun_rst = hns3_read_dev(hw, HNS3_FUN_RST_ING);
hns3_err(hw, "Delayed VF reset global: %x fun_rst: %x",
global, fun_rst);
hns3_atomic_set_bit(HNS3_VF_RESET, &hw->reset.pending);
} else {
global = hns3_read_dev(hw, HNS3_GLOBAL_RESET_REG);
fun_rst = hns3_read_dev(hw, HNS3_FUN_RST_ING);
hns3_err(hw, "Delayed IMP reset global: %x fun_rst: %x",
global, fun_rst);
hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending);
}

hns3_schedule_delayed_reset(hns);

return -EIO;
}

Expand Down Expand Up @@ -317,6 +337,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 {
Expand All @@ -329,6 +350,11 @@ 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);
Expand Down Expand Up @@ -484,6 +510,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);
Expand Down
Loading

0 comments on commit 2790c64

Please sign in to comment.