Commit e5f0fd27 authored by Ben Hutchings's avatar Ben Hutchings

sfc: Read MC firmware version when requested through ethtool

We currently make no use of siena_nic_data::fw_{version,build} except
to format the firmware version for ethtool_get_drvinfo().  Since we
only read the version at start of day, this information is incorrect
after an MC firmware update.  Remove the cached version information
and read it via MCDI whenever it is requested.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent a526f140
...@@ -237,8 +237,8 @@ static void efx_ethtool_get_drvinfo(struct net_device *net_dev, ...@@ -237,8 +237,8 @@ static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version)); strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
siena_print_fwver(efx, info->fw_version, efx_mcdi_print_fwver(efx, info->fw_version,
sizeof(info->fw_version)); sizeof(info->fw_version));
strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
} }
......
...@@ -602,7 +602,7 @@ void efx_mcdi_process_event(struct efx_channel *channel, ...@@ -602,7 +602,7 @@ void efx_mcdi_process_event(struct efx_channel *channel,
************************************************************************** **************************************************************************
*/ */
int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build) void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len)
{ {
u8 outbuf[ALIGN(MC_CMD_GET_VERSION_V1_OUT_LEN, 4)]; u8 outbuf[ALIGN(MC_CMD_GET_VERSION_V1_OUT_LEN, 4)];
size_t outlength; size_t outlength;
...@@ -616,29 +616,20 @@ int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build) ...@@ -616,29 +616,20 @@ int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build)
if (rc) if (rc)
goto fail; goto fail;
if (outlength == MC_CMD_GET_VERSION_V0_OUT_LEN) {
*version = 0;
*build = MCDI_DWORD(outbuf, GET_VERSION_OUT_FIRMWARE);
return 0;
}
if (outlength < MC_CMD_GET_VERSION_V1_OUT_LEN) { if (outlength < MC_CMD_GET_VERSION_V1_OUT_LEN) {
rc = -EIO; rc = -EIO;
goto fail; goto fail;
} }
ver_words = (__le16 *)MCDI_PTR(outbuf, GET_VERSION_OUT_VERSION); ver_words = (__le16 *)MCDI_PTR(outbuf, GET_VERSION_OUT_VERSION);
*version = (((u64)le16_to_cpu(ver_words[0]) << 48) | snprintf(buf, len, "%u.%u.%u.%u",
((u64)le16_to_cpu(ver_words[1]) << 32) | le16_to_cpu(ver_words[0]), le16_to_cpu(ver_words[1]),
((u64)le16_to_cpu(ver_words[2]) << 16) | le16_to_cpu(ver_words[2]), le16_to_cpu(ver_words[3]));
le16_to_cpu(ver_words[3])); return;
*build = MCDI_DWORD(outbuf, GET_VERSION_OUT_FIRMWARE);
return 0;
fail: fail:
netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
return rc; buf[0] = 0;
} }
int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
......
...@@ -93,7 +93,7 @@ extern void efx_mcdi_process_event(struct efx_channel *channel, ...@@ -93,7 +93,7 @@ extern void efx_mcdi_process_event(struct efx_channel *channel,
#define MCDI_EVENT_FIELD(_ev, _field) \ #define MCDI_EVENT_FIELD(_ev, _field) \
EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
extern int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build); extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
bool *was_attached_out); bool *was_attached_out);
extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
......
...@@ -142,20 +142,14 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx) ...@@ -142,20 +142,14 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
/** /**
* struct siena_nic_data - Siena NIC state * struct siena_nic_data - Siena NIC state
* @fw_version: Management controller firmware version
* @fw_build: Firmware build number
* @mcdi: Management-Controller-to-Driver Interface * @mcdi: Management-Controller-to-Driver Interface
* @wol_filter_id: Wake-on-LAN packet filter id * @wol_filter_id: Wake-on-LAN packet filter id
*/ */
struct siena_nic_data { struct siena_nic_data {
u64 fw_version;
u32 fw_build;
struct efx_mcdi_iface mcdi; struct efx_mcdi_iface mcdi;
int wol_filter_id; int wol_filter_id;
}; };
extern void siena_print_fwver(struct efx_nic *efx, char *buf, size_t len);
extern struct efx_nic_type falcon_a1_nic_type; extern struct efx_nic_type falcon_a1_nic_type;
extern struct efx_nic_type falcon_b0_nic_type; extern struct efx_nic_type falcon_b0_nic_type;
extern struct efx_nic_type siena_a0_nic_type; extern struct efx_nic_type siena_a0_nic_type;
......
...@@ -227,13 +227,6 @@ static int siena_probe_nic(struct efx_nic *efx) ...@@ -227,13 +227,6 @@ static int siena_probe_nic(struct efx_nic *efx)
if (rc) if (rc)
goto fail1; goto fail1;
rc = efx_mcdi_fwver(efx, &nic_data->fw_version, &nic_data->fw_build);
if (rc) {
netif_err(efx, probe, efx->net_dev,
"Failed to read MCPU firmware version - rc %d\n", rc);
goto fail1; /* MCPU absent? */
}
/* Let the BMC know that the driver is now in charge of link and /* Let the BMC know that the driver is now in charge of link and
* filter settings. We must do this before we reset the NIC */ * filter settings. We must do this before we reset the NIC */
rc = efx_mcdi_drv_attach(efx, true, &already_attached); rc = efx_mcdi_drv_attach(efx, true, &already_attached);
...@@ -514,16 +507,6 @@ static void siena_stop_nic_stats(struct efx_nic *efx) ...@@ -514,16 +507,6 @@ static void siena_stop_nic_stats(struct efx_nic *efx)
efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 0); efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 0);
} }
void siena_print_fwver(struct efx_nic *efx, char *buf, size_t len)
{
struct siena_nic_data *nic_data = efx->nic_data;
snprintf(buf, len, "%u.%u.%u.%u",
(unsigned int)(nic_data->fw_version >> 48),
(unsigned int)(nic_data->fw_version >> 32 & 0xffff),
(unsigned int)(nic_data->fw_version >> 16 & 0xffff),
(unsigned int)(nic_data->fw_version & 0xffff));
}
/************************************************************************** /**************************************************************************
* *
* Wake on LAN * Wake on LAN
......
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