aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2011-02-24 18:57:47 -0500
committerBen Hutchings <bhutchings@solarflare.com>2011-02-28 18:57:23 -0500
commite5f0fd278084d79d6be0920043519749374b0507 (patch)
treeafd06055d8d1058ceabc349396b087698183d237 /drivers
parenta526f140b22131376b0e49577210e6af73e2b89f (diff)
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: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sfc/ethtool.c4
-rw-r--r--drivers/net/sfc/mcdi.c21
-rw-r--r--drivers/net/sfc/mcdi.h2
-rw-r--r--drivers/net/sfc/nic.h6
-rw-r--r--drivers/net/sfc/siena.c17
5 files changed, 9 insertions, 41 deletions
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 272cfe724e1b..3e974b11db0e 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -237,8 +237,8 @@ static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
237 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); 237 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
238 strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version)); 238 strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
239 if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) 239 if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
240 siena_print_fwver(efx, info->fw_version, 240 efx_mcdi_print_fwver(efx, info->fw_version,
241 sizeof(info->fw_version)); 241 sizeof(info->fw_version));
242 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); 242 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
243} 243}
244 244
diff --git a/drivers/net/sfc/mcdi.c b/drivers/net/sfc/mcdi.c
index b716e827b291..88e786b11ed1 100644
--- a/drivers/net/sfc/mcdi.c
+++ b/drivers/net/sfc/mcdi.c
@@ -602,7 +602,7 @@ void efx_mcdi_process_event(struct efx_channel *channel,
602 ************************************************************************** 602 **************************************************************************
603 */ 603 */
604 604
605int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build) 605void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len)
606{ 606{
607 u8 outbuf[ALIGN(MC_CMD_GET_VERSION_V1_OUT_LEN, 4)]; 607 u8 outbuf[ALIGN(MC_CMD_GET_VERSION_V1_OUT_LEN, 4)];
608 size_t outlength; 608 size_t outlength;
@@ -616,29 +616,20 @@ int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build)
616 if (rc) 616 if (rc)
617 goto fail; 617 goto fail;
618 618
619 if (outlength == MC_CMD_GET_VERSION_V0_OUT_LEN) {
620 *version = 0;
621 *build = MCDI_DWORD(outbuf, GET_VERSION_OUT_FIRMWARE);
622 return 0;
623 }
624
625 if (outlength < MC_CMD_GET_VERSION_V1_OUT_LEN) { 619 if (outlength < MC_CMD_GET_VERSION_V1_OUT_LEN) {
626 rc = -EIO; 620 rc = -EIO;
627 goto fail; 621 goto fail;
628 } 622 }
629 623
630 ver_words = (__le16 *)MCDI_PTR(outbuf, GET_VERSION_OUT_VERSION); 624 ver_words = (__le16 *)MCDI_PTR(outbuf, GET_VERSION_OUT_VERSION);
631 *version = (((u64)le16_to_cpu(ver_words[0]) << 48) | 625 snprintf(buf, len, "%u.%u.%u.%u",
632 ((u64)le16_to_cpu(ver_words[1]) << 32) | 626 le16_to_cpu(ver_words[0]), le16_to_cpu(ver_words[1]),
633 ((u64)le16_to_cpu(ver_words[2]) << 16) | 627 le16_to_cpu(ver_words[2]), le16_to_cpu(ver_words[3]));
634 le16_to_cpu(ver_words[3])); 628 return;
635 *build = MCDI_DWORD(outbuf, GET_VERSION_OUT_FIRMWARE);
636
637 return 0;
638 629
639fail: 630fail:
640 netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); 631 netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
641 return rc; 632 buf[0] = 0;
642} 633}
643 634
644int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 635int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
diff --git a/drivers/net/sfc/mcdi.h b/drivers/net/sfc/mcdi.h
index c792f1d65e48..9bac250143d9 100644
--- a/drivers/net/sfc/mcdi.h
+++ b/drivers/net/sfc/mcdi.h
@@ -93,7 +93,7 @@ extern void efx_mcdi_process_event(struct efx_channel *channel,
93#define MCDI_EVENT_FIELD(_ev, _field) \ 93#define MCDI_EVENT_FIELD(_ev, _field) \
94 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) 94 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
95 95
96extern int efx_mcdi_fwver(struct efx_nic *efx, u64 *version, u32 *build); 96extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
97extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 97extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
98 bool *was_attached_out); 98 bool *was_attached_out);
99extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 99extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
index eb0586925b51..17407eac0030 100644
--- a/drivers/net/sfc/nic.h
+++ b/drivers/net/sfc/nic.h
@@ -142,20 +142,14 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
142 142
143/** 143/**
144 * struct siena_nic_data - Siena NIC state 144 * struct siena_nic_data - Siena NIC state
145 * @fw_version: Management controller firmware version
146 * @fw_build: Firmware build number
147 * @mcdi: Management-Controller-to-Driver Interface 145 * @mcdi: Management-Controller-to-Driver Interface
148 * @wol_filter_id: Wake-on-LAN packet filter id 146 * @wol_filter_id: Wake-on-LAN packet filter id
149 */ 147 */
150struct siena_nic_data { 148struct siena_nic_data {
151 u64 fw_version;
152 u32 fw_build;
153 struct efx_mcdi_iface mcdi; 149 struct efx_mcdi_iface mcdi;
154 int wol_filter_id; 150 int wol_filter_id;
155}; 151};
156 152
157extern void siena_print_fwver(struct efx_nic *efx, char *buf, size_t len);
158
159extern struct efx_nic_type falcon_a1_nic_type; 153extern struct efx_nic_type falcon_a1_nic_type;
160extern struct efx_nic_type falcon_b0_nic_type; 154extern struct efx_nic_type falcon_b0_nic_type;
161extern struct efx_nic_type siena_a0_nic_type; 155extern struct efx_nic_type siena_a0_nic_type;
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index bf8456176443..07b59a8c9a4c 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -227,13 +227,6 @@ static int siena_probe_nic(struct efx_nic *efx)
227 if (rc) 227 if (rc)
228 goto fail1; 228 goto fail1;
229 229
230 rc = efx_mcdi_fwver(efx, &nic_data->fw_version, &nic_data->fw_build);
231 if (rc) {
232 netif_err(efx, probe, efx->net_dev,
233 "Failed to read MCPU firmware version - rc %d\n", rc);
234 goto fail1; /* MCPU absent? */
235 }
236
237 /* Let the BMC know that the driver is now in charge of link and 230 /* Let the BMC know that the driver is now in charge of link and
238 * filter settings. We must do this before we reset the NIC */ 231 * filter settings. We must do this before we reset the NIC */
239 rc = efx_mcdi_drv_attach(efx, true, &already_attached); 232 rc = efx_mcdi_drv_attach(efx, true, &already_attached);
@@ -514,16 +507,6 @@ static void siena_stop_nic_stats(struct efx_nic *efx)
514 efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 0); 507 efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 0);
515} 508}
516 509
517void siena_print_fwver(struct efx_nic *efx, char *buf, size_t len)
518{
519 struct siena_nic_data *nic_data = efx->nic_data;
520 snprintf(buf, len, "%u.%u.%u.%u",
521 (unsigned int)(nic_data->fw_version >> 48),
522 (unsigned int)(nic_data->fw_version >> 32 & 0xffff),
523 (unsigned int)(nic_data->fw_version >> 16 & 0xffff),
524 (unsigned int)(nic_data->fw_version & 0xffff));
525}
526
527/************************************************************************** 510/**************************************************************************
528 * 511 *
529 * Wake on LAN 512 * Wake on LAN