Skip to content

Commit ec5d31e

Browse files
Michael Chandavem330
authored andcommitted
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: Vasundhara Volam <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 91b9be4 commit ec5d31e

File tree

2 files changed

+89
-20
lines changed

2 files changed

+89
-20
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 87 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8523,11 +8523,14 @@ static int bnxt_hwrm_shutdown_link(struct bnxt *bp)
85238523
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
85248524
}
85258525

8526+
static int bnxt_fw_init_one(struct bnxt *bp);
8527+
85268528
static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
85278529
{
85288530
struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
85298531
struct hwrm_func_drv_if_change_input req = {0};
8530-
bool resc_reinit = false;
8532+
bool resc_reinit = false, fw_reset = false;
8533+
u32 flags = 0;
85318534
int rc;
85328535

85338536
if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE))
@@ -8538,26 +8541,53 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
85388541
req.flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP);
85398542
mutex_lock(&bp->hwrm_cmd_lock);
85408543
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
8541-
if (!rc && (resp->flags &
8542-
cpu_to_le32(FUNC_DRV_IF_CHANGE_RESP_FLAGS_RESC_CHANGE)))
8543-
resc_reinit = true;
8544+
if (!rc)
8545+
flags = le32_to_cpu(resp->flags);
85448546
mutex_unlock(&bp->hwrm_cmd_lock);
8547+
if (rc)
8548+
return rc;
85458549

8546-
if (up && resc_reinit && BNXT_NEW_RM(bp)) {
8547-
struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
8550+
if (!up)
8551+
return 0;
85488552

8549-
rc = bnxt_hwrm_func_resc_qcaps(bp, true);
8550-
hw_resc->resv_cp_rings = 0;
8551-
hw_resc->resv_stat_ctxs = 0;
8552-
hw_resc->resv_irqs = 0;
8553-
hw_resc->resv_tx_rings = 0;
8554-
hw_resc->resv_rx_rings = 0;
8555-
hw_resc->resv_hw_ring_grps = 0;
8556-
hw_resc->resv_vnics = 0;
8557-
bp->tx_nr_rings = 0;
8558-
bp->rx_nr_rings = 0;
8553+
if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_RESC_CHANGE)
8554+
resc_reinit = true;
8555+
if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE)
8556+
fw_reset = true;
8557+
8558+
if (resc_reinit || fw_reset) {
8559+
if (fw_reset) {
8560+
rc = bnxt_fw_init_one(bp);
8561+
if (rc) {
8562+
set_bit(BNXT_STATE_ABORT_ERR, &bp->state);
8563+
return rc;
8564+
}
8565+
bnxt_clear_int_mode(bp);
8566+
rc = bnxt_init_int_mode(bp);
8567+
if (rc) {
8568+
netdev_err(bp->dev, "init int mode failed\n");
8569+
return rc;
8570+
}
8571+
set_bit(BNXT_STATE_FW_RESET_DET, &bp->state);
8572+
}
8573+
if (BNXT_NEW_RM(bp)) {
8574+
struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
8575+
8576+
rc = bnxt_hwrm_func_resc_qcaps(bp, true);
8577+
hw_resc->resv_cp_rings = 0;
8578+
hw_resc->resv_stat_ctxs = 0;
8579+
hw_resc->resv_irqs = 0;
8580+
hw_resc->resv_tx_rings = 0;
8581+
hw_resc->resv_rx_rings = 0;
8582+
hw_resc->resv_hw_ring_grps = 0;
8583+
hw_resc->resv_vnics = 0;
8584+
if (!fw_reset) {
8585+
bp->tx_nr_rings = 0;
8586+
bp->rx_nr_rings = 0;
8587+
}
8588+
}
85598589
}
8560-
return rc;
8590+
return 0;
85618591
}
85628592

85638593
static int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
@@ -8977,12 +9007,28 @@ static int bnxt_open(struct net_device *dev)
89779007
struct bnxt *bp = netdev_priv(dev);
89789008
int rc;
89799009

8980-
bnxt_hwrm_if_change(bp, true);
8981-
rc = __bnxt_open_nic(bp, true, true);
9010+
if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
9011+
netdev_err(bp->dev, "A previous firmware reset did not complete, aborting\n");
9012+
return -ENODEV;
9013+
}
9014+
9015+
rc = bnxt_hwrm_if_change(bp, true);
89829016
if (rc)
9017+
return rc;
9018+
rc = __bnxt_open_nic(bp, true, true);
9019+
if (rc) {
89839020
bnxt_hwrm_if_change(bp, false);
9021+
} else {
9022+
if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state) &&
9023+
BNXT_PF(bp)) {
9024+
struct bnxt_pf_info *pf = &bp->pf;
9025+
int n = pf->active_vfs;
89849026

8985-
bnxt_hwmon_open(bp);
9027+
if (n)
9028+
bnxt_cfg_hw_sriov(bp, &n);
9029+
}
9030+
bnxt_hwmon_open(bp);
9031+
}
89869032

89879033
return rc;
89889034
}
@@ -10075,6 +10121,27 @@ static void bnxt_fw_init_one_p3(struct bnxt *bp)
1007510121
bnxt_hwrm_coal_params_qcaps(bp);
1007610122
}
1007710123

10124+
static int bnxt_fw_init_one(struct bnxt *bp)
10125+
{
10126+
int rc;
10127+
10128+
rc = bnxt_fw_init_one_p1(bp);
10129+
if (rc) {
10130+
netdev_err(bp->dev, "Firmware init phase 1 failed\n");
10131+
return rc;
10132+
}
10133+
rc = bnxt_fw_init_one_p2(bp);
10134+
if (rc) {
10135+
netdev_err(bp->dev, "Firmware init phase 2 failed\n");
10136+
return rc;
10137+
}
10138+
rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false);
10139+
if (rc)
10140+
return rc;
10141+
bnxt_fw_init_one_p3(bp);
10142+
return 0;
10143+
}
10144+
1007810145
static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
1007910146
{
1008010147
int rc;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,8 @@ struct bnxt {
15551555
#define BNXT_STATE_OPEN 0
15561556
#define BNXT_STATE_IN_SP_TASK 1
15571557
#define BNXT_STATE_READ_STATS 2
1558+
#define BNXT_STATE_FW_RESET_DET 3
1559+
#define BNXT_STATE_ABORT_ERR 5
15581560

15591561
struct bnxt_irq *irq_tbl;
15601562
int total_irqs;

0 commit comments

Comments
 (0)