Skip to content

Commit 8e73714

Browse files
ecree-solarflaredavem330
authored andcommitted
sfc_ef100: check firmware version at start-of-day
Early in EF100 development there was a different format of event descriptor; if the NIC is somehow running the very old firmware which will use that format, fail the probe. Signed-off-by: Edward Cree <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 215602a commit 8e73714

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

drivers/net/ethernet/sfc/ef100_nic.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,44 @@ const struct efx_nic_type ef100_pf_nic_type = {
485485

486486
};
487487

488+
static int compare_versions(const char *a, const char *b)
489+
{
490+
int a_major, a_minor, a_point, a_patch;
491+
int b_major, b_minor, b_point, b_patch;
492+
int a_matched, b_matched;
493+
494+
a_matched = sscanf(a, "%d.%d.%d.%d", &a_major, &a_minor, &a_point, &a_patch);
495+
b_matched = sscanf(b, "%d.%d.%d.%d", &b_major, &b_minor, &b_point, &b_patch);
496+
497+
if (a_matched == 4 && b_matched != 4)
498+
return +1;
499+
500+
if (a_matched != 4 && b_matched == 4)
501+
return -1;
502+
503+
if (a_matched != 4 && b_matched != 4)
504+
return 0;
505+
506+
if (a_major != b_major)
507+
return a_major - b_major;
508+
509+
if (a_minor != b_minor)
510+
return a_minor - b_minor;
511+
512+
if (a_point != b_point)
513+
return a_point - b_point;
514+
515+
return a_patch - b_patch;
516+
}
517+
488518
/* NIC probe and remove
489519
*/
490520
static int ef100_probe_main(struct efx_nic *efx)
491521
{
492522
unsigned int bar_size = resource_size(&efx->pci_dev->resource[efx->mem_bar]);
493523
struct net_device *net_dev = efx->net_dev;
494524
struct ef100_nic_data *nic_data;
525+
char fw_version[32];
495526
int i, rc;
496527

497528
if (WARN_ON(bar_size == 0))
@@ -562,6 +593,15 @@ static int ef100_probe_main(struct efx_nic *efx)
562593
goto fail;
563594
efx->port_num = rc;
564595

596+
efx_mcdi_print_fwver(efx, fw_version, sizeof(fw_version));
597+
netif_dbg(efx, drv, efx->net_dev, "Firmware version %s\n", fw_version);
598+
599+
if (compare_versions(fw_version, "1.1.0.1000") < 0) {
600+
netif_info(efx, drv, efx->net_dev, "Firmware uses old event descriptors\n");
601+
rc = -EINVAL;
602+
goto fail;
603+
}
604+
565605
rc = ef100_phy_probe(efx);
566606
if (rc)
567607
goto fail;

0 commit comments

Comments
 (0)