Skip to content

Commit 8e42aef

Browse files
Kalesh APdavem330
authored andcommitted
bnxt_en: refactor error handling of HWRM_NVM_INSTALL_UPDATE
This is in anticipation of handling more "cmd_err" from FW in the next patch. Reviewed-by: Somnath Kotur <[email protected]> Reviewed-by: Edwin Peer <[email protected]> Signed-off-by: Kalesh AP <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2057b8b commit 8e42aef

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,7 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
25122512
u8 *kmem = NULL;
25132513
u32 modify_len;
25142514
u32 item_len;
2515+
u8 cmd_err;
25152516
u16 index;
25162517
int rc;
25172518

@@ -2595,6 +2596,8 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
25952596
}
25962597

25972598
rc = hwrm_req_send_silent(bp, install);
2599+
if (!rc)
2600+
break;
25982601

25992602
if (defrag_attempted) {
26002603
/* We have tried to defragment already in the previous
@@ -2603,15 +2606,20 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
26032606
break;
26042607
}
26052608

2606-
if (rc && ((struct hwrm_err_output *)resp)->cmd_err ==
2607-
NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) {
2609+
cmd_err = ((struct hwrm_err_output *)resp)->cmd_err;
2610+
2611+
switch (cmd_err) {
2612+
case NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR:
26082613
install->flags =
26092614
cpu_to_le16(NVM_INSTALL_UPDATE_REQ_FLAGS_ALLOWED_TO_DEFRAG);
26102615

26112616
rc = hwrm_req_send_silent(bp, install);
2617+
if (!rc)
2618+
break;
2619+
2620+
cmd_err = ((struct hwrm_err_output *)resp)->cmd_err;
26122621

2613-
if (rc && ((struct hwrm_err_output *)resp)->cmd_err ==
2614-
NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_SPACE) {
2622+
if (cmd_err == NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_SPACE) {
26152623
/* FW has cleared NVM area, driver will create
26162624
* UPDATE directory and try the flash again
26172625
*/
@@ -2621,11 +2629,13 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
26212629
BNX_DIR_TYPE_UPDATE,
26222630
BNX_DIR_ORDINAL_FIRST,
26232631
0, 0, item_len, NULL, 0);
2624-
} else if (rc) {
2625-
netdev_err(dev, "HWRM_NVM_INSTALL_UPDATE failure rc :%x\n", rc);
2632+
if (!rc)
2633+
break;
26262634
}
2627-
} else if (rc) {
2628-
netdev_err(dev, "HWRM_NVM_INSTALL_UPDATE failure rc :%x\n", rc);
2635+
fallthrough;
2636+
default:
2637+
netdev_err(dev, "HWRM_NVM_INSTALL_UPDATE failure rc :%x cmd_err :%x\n",
2638+
rc, cmd_err);
26292639
}
26302640
} while (defrag_attempted && !rc);
26312641

0 commit comments

Comments
 (0)