Commit ec5d31e3 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Handle firmware reset status during IF_UP.

During IF_UP, newer firmware has a new status flag that indicates that
firmware has reset.  Add new function bnxt_fw_init_one() to re-probe the
firmware and re-setup VF resources on the PF if necessary.  If the
re-probe fails, set a flag to prevent bnxt_open() from proceeding again.
Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 91b9be48
...@@ -8523,11 +8523,14 @@ static int bnxt_hwrm_shutdown_link(struct bnxt *bp) ...@@ -8523,11 +8523,14 @@ static int bnxt_hwrm_shutdown_link(struct bnxt *bp)
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
} }
static int bnxt_fw_init_one(struct bnxt *bp);
static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
{ {
struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr; struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
struct hwrm_func_drv_if_change_input req = {0}; struct hwrm_func_drv_if_change_input req = {0};
bool resc_reinit = false; bool resc_reinit = false, fw_reset = false;
u32 flags = 0;
int rc; int rc;
if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE))
...@@ -8538,26 +8541,53 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) ...@@ -8538,26 +8541,53 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
req.flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP); req.flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP);
mutex_lock(&bp->hwrm_cmd_lock); mutex_lock(&bp->hwrm_cmd_lock);
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
if (!rc && (resp->flags & if (!rc)
cpu_to_le32(FUNC_DRV_IF_CHANGE_RESP_FLAGS_RESC_CHANGE))) flags = le32_to_cpu(resp->flags);
resc_reinit = true;
mutex_unlock(&bp->hwrm_cmd_lock); mutex_unlock(&bp->hwrm_cmd_lock);
if (rc)
return rc;
if (up && resc_reinit && BNXT_NEW_RM(bp)) { if (!up)
struct bnxt_hw_resc *hw_resc = &bp->hw_resc; return 0;
rc = bnxt_hwrm_func_resc_qcaps(bp, true); if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_RESC_CHANGE)
hw_resc->resv_cp_rings = 0; resc_reinit = true;
hw_resc->resv_stat_ctxs = 0; if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE)
hw_resc->resv_irqs = 0; fw_reset = true;
hw_resc->resv_tx_rings = 0;
hw_resc->resv_rx_rings = 0; if (resc_reinit || fw_reset) {
hw_resc->resv_hw_ring_grps = 0; if (fw_reset) {
hw_resc->resv_vnics = 0; rc = bnxt_fw_init_one(bp);
bp->tx_nr_rings = 0; if (rc) {
bp->rx_nr_rings = 0; set_bit(BNXT_STATE_ABORT_ERR, &bp->state);
return rc;
}
bnxt_clear_int_mode(bp);
rc = bnxt_init_int_mode(bp);
if (rc) {
netdev_err(bp->dev, "init int mode failed\n");
return rc;
}
set_bit(BNXT_STATE_FW_RESET_DET, &bp->state);
}
if (BNXT_NEW_RM(bp)) {
struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
rc = bnxt_hwrm_func_resc_qcaps(bp, true);
hw_resc->resv_cp_rings = 0;
hw_resc->resv_stat_ctxs = 0;
hw_resc->resv_irqs = 0;
hw_resc->resv_tx_rings = 0;
hw_resc->resv_rx_rings = 0;
hw_resc->resv_hw_ring_grps = 0;
hw_resc->resv_vnics = 0;
if (!fw_reset) {
bp->tx_nr_rings = 0;
bp->rx_nr_rings = 0;
}
}
} }
return rc; return 0;
} }
static int bnxt_hwrm_port_led_qcaps(struct bnxt *bp) static int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
...@@ -8977,12 +9007,28 @@ static int bnxt_open(struct net_device *dev) ...@@ -8977,12 +9007,28 @@ static int bnxt_open(struct net_device *dev)
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
int rc; int rc;
bnxt_hwrm_if_change(bp, true); if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
rc = __bnxt_open_nic(bp, true, true); netdev_err(bp->dev, "A previous firmware reset did not complete, aborting\n");
return -ENODEV;
}
rc = bnxt_hwrm_if_change(bp, true);
if (rc) if (rc)
return rc;
rc = __bnxt_open_nic(bp, true, true);
if (rc) {
bnxt_hwrm_if_change(bp, false); bnxt_hwrm_if_change(bp, false);
} else {
if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state) &&
BNXT_PF(bp)) {
struct bnxt_pf_info *pf = &bp->pf;
int n = pf->active_vfs;
bnxt_hwmon_open(bp); if (n)
bnxt_cfg_hw_sriov(bp, &n);
}
bnxt_hwmon_open(bp);
}
return rc; return rc;
} }
...@@ -10075,6 +10121,27 @@ static void bnxt_fw_init_one_p3(struct bnxt *bp) ...@@ -10075,6 +10121,27 @@ static void bnxt_fw_init_one_p3(struct bnxt *bp)
bnxt_hwrm_coal_params_qcaps(bp); bnxt_hwrm_coal_params_qcaps(bp);
} }
static int bnxt_fw_init_one(struct bnxt *bp)
{
int rc;
rc = bnxt_fw_init_one_p1(bp);
if (rc) {
netdev_err(bp->dev, "Firmware init phase 1 failed\n");
return rc;
}
rc = bnxt_fw_init_one_p2(bp);
if (rc) {
netdev_err(bp->dev, "Firmware init phase 2 failed\n");
return rc;
}
rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false);
if (rc)
return rc;
bnxt_fw_init_one_p3(bp);
return 0;
}
static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
{ {
int rc; int rc;
......
...@@ -1555,6 +1555,8 @@ struct bnxt { ...@@ -1555,6 +1555,8 @@ struct bnxt {
#define BNXT_STATE_OPEN 0 #define BNXT_STATE_OPEN 0
#define BNXT_STATE_IN_SP_TASK 1 #define BNXT_STATE_IN_SP_TASK 1
#define BNXT_STATE_READ_STATS 2 #define BNXT_STATE_READ_STATS 2
#define BNXT_STATE_FW_RESET_DET 3
#define BNXT_STATE_ABORT_ERR 5
struct bnxt_irq *irq_tbl; struct bnxt_irq *irq_tbl;
int total_irqs; int total_irqs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment