Skip to content

Commit cfcb942

Browse files
Alejandro Lucerodavem330
authored andcommitted
sfc: fix devlink info error handling
Avoid early devlink info return if errors arise with MCDI commands executed for getting the required info from the device. The rationale is some commands can fail but later ones could still give useful data. Moreover, some nvram partitions could not be present which needs to be handled as a non error. The specific errors are reported through system messages and if any error appears, it will be reported generically through extack. Fixes 14743dd ("sfc: add devlink info support for ef100") Signed-off-by: Alejandro Lucero <[email protected]> Acked-by: Martin Habets <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3511227 commit cfcb942

File tree

1 file changed

+45
-50
lines changed

1 file changed

+45
-50
lines changed

drivers/net/ethernet/sfc/efx_devlink.c

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,14 @@ static int efx_devlink_info_nvram_partition(struct efx_nic *efx,
171171

172172
rc = efx_mcdi_nvram_metadata(efx, partition_type, NULL, version, NULL,
173173
0);
174+
175+
/* If the partition does not exist, that is not an error. */
176+
if (rc == -ENOENT)
177+
return 0;
178+
174179
if (rc) {
175-
netif_err(efx, drv, efx->net_dev, "mcdi nvram %s: failed\n",
176-
version_name);
180+
netif_err(efx, drv, efx->net_dev, "mcdi nvram %s: failed (rc=%d)\n",
181+
version_name, rc);
177182
return rc;
178183
}
179184

@@ -187,36 +192,33 @@ static int efx_devlink_info_nvram_partition(struct efx_nic *efx,
187192
static int efx_devlink_info_stored_versions(struct efx_nic *efx,
188193
struct devlink_info_req *req)
189194
{
190-
int rc;
191-
192-
rc = efx_devlink_info_nvram_partition(efx, req,
193-
NVRAM_PARTITION_TYPE_BUNDLE,
194-
DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID);
195-
if (rc)
196-
return rc;
197-
198-
rc = efx_devlink_info_nvram_partition(efx, req,
199-
NVRAM_PARTITION_TYPE_MC_FIRMWARE,
200-
DEVLINK_INFO_VERSION_GENERIC_FW_MGMT);
201-
if (rc)
202-
return rc;
203-
204-
rc = efx_devlink_info_nvram_partition(efx, req,
205-
NVRAM_PARTITION_TYPE_SUC_FIRMWARE,
206-
EFX_DEVLINK_INFO_VERSION_FW_MGMT_SUC);
207-
if (rc)
208-
return rc;
209-
210-
rc = efx_devlink_info_nvram_partition(efx, req,
211-
NVRAM_PARTITION_TYPE_EXPANSION_ROM,
212-
EFX_DEVLINK_INFO_VERSION_FW_EXPROM);
213-
if (rc)
214-
return rc;
195+
int err;
215196

216-
rc = efx_devlink_info_nvram_partition(efx, req,
217-
NVRAM_PARTITION_TYPE_EXPANSION_UEFI,
218-
EFX_DEVLINK_INFO_VERSION_FW_UEFI);
219-
return rc;
197+
/* We do not care here about the specific error but just if an error
198+
* happened. The specific error will be reported inside the call
199+
* through system messages, and if any error happened in any call
200+
* below, we report it through extack.
201+
*/
202+
err = efx_devlink_info_nvram_partition(efx, req,
203+
NVRAM_PARTITION_TYPE_BUNDLE,
204+
DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID);
205+
206+
err |= efx_devlink_info_nvram_partition(efx, req,
207+
NVRAM_PARTITION_TYPE_MC_FIRMWARE,
208+
DEVLINK_INFO_VERSION_GENERIC_FW_MGMT);
209+
210+
err |= efx_devlink_info_nvram_partition(efx, req,
211+
NVRAM_PARTITION_TYPE_SUC_FIRMWARE,
212+
EFX_DEVLINK_INFO_VERSION_FW_MGMT_SUC);
213+
214+
err |= efx_devlink_info_nvram_partition(efx, req,
215+
NVRAM_PARTITION_TYPE_EXPANSION_ROM,
216+
EFX_DEVLINK_INFO_VERSION_FW_EXPROM);
217+
218+
err |= efx_devlink_info_nvram_partition(efx, req,
219+
NVRAM_PARTITION_TYPE_EXPANSION_UEFI,
220+
EFX_DEVLINK_INFO_VERSION_FW_UEFI);
221+
return err;
220222
}
221223

222224
#define EFX_VER_FLAG(_f) \
@@ -587,27 +589,20 @@ static int efx_devlink_info_get(struct devlink *devlink,
587589
{
588590
struct efx_devlink *devlink_private = devlink_priv(devlink);
589591
struct efx_nic *efx = devlink_private->efx;
590-
int rc;
592+
int err;
591593

592-
/* Several different MCDI commands are used. We report first error
593-
* through extack returning at that point. Specific error
594-
* information via system messages.
594+
/* Several different MCDI commands are used. We report if errors
595+
* happened through extack. Specific error information via system
596+
* messages inside the calls.
595597
*/
596-
rc = efx_devlink_info_board_cfg(efx, req);
597-
if (rc) {
598-
NL_SET_ERR_MSG_MOD(extack, "Getting board info failed");
599-
return rc;
600-
}
601-
rc = efx_devlink_info_stored_versions(efx, req);
602-
if (rc) {
603-
NL_SET_ERR_MSG_MOD(extack, "Getting stored versions failed");
604-
return rc;
605-
}
606-
rc = efx_devlink_info_running_versions(efx, req);
607-
if (rc) {
608-
NL_SET_ERR_MSG_MOD(extack, "Getting running versions failed");
609-
return rc;
610-
}
598+
err = efx_devlink_info_board_cfg(efx, req);
599+
600+
err |= efx_devlink_info_stored_versions(efx, req);
601+
602+
err |= efx_devlink_info_running_versions(efx, req);
603+
604+
if (err)
605+
NL_SET_ERR_MSG_MOD(extack, "Errors when getting device info. Check system messages");
611606

612607
return 0;
613608
}

0 commit comments

Comments
 (0)