All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward Cree <ecree@solarflare.com>
To: <linux-net-drivers@solarflare.com>, <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>
Subject: [PATCH v2 net-next 01/11] sfc_ef100: check firmware version at start-of-day
Date: Fri, 31 Jul 2020 13:58:01 +0100	[thread overview]
Message-ID: <01fb1600-3f84-c1a8-ef02-68e32fb9402d@solarflare.com> (raw)
In-Reply-To: <31de2e73-bce7-6c9d-0c20-49b32e2043cc@solarflare.com>

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 <ecree@solarflare.com>
---
 drivers/net/ethernet/sfc/ef100_nic.c | 40 ++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index 6a00f2a2dc2b..75131bcf4f1a 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -485,6 +485,36 @@ const struct efx_nic_type ef100_pf_nic_type = {
 
 };
 
+static int compare_versions(const char *a, const char *b)
+{
+	int a_major, a_minor, a_point, a_patch;
+	int b_major, b_minor, b_point, b_patch;
+	int a_matched, b_matched;
+
+	a_matched = sscanf(a, "%d.%d.%d.%d", &a_major, &a_minor, &a_point, &a_patch);
+	b_matched = sscanf(b, "%d.%d.%d.%d", &b_major, &b_minor, &b_point, &b_patch);
+
+	if (a_matched == 4 && b_matched != 4)
+		return +1;
+
+	if (a_matched != 4 && b_matched == 4)
+		return -1;
+
+	if (a_matched != 4 && b_matched != 4)
+		return 0;
+
+	if (a_major != b_major)
+		return a_major - b_major;
+
+	if (a_minor != b_minor)
+		return a_minor - b_minor;
+
+	if (a_point != b_point)
+		return a_point - b_point;
+
+	return a_patch - b_patch;
+}
+
 /*	NIC probe and remove
  */
 static int ef100_probe_main(struct efx_nic *efx)
@@ -492,6 +522,7 @@ static int ef100_probe_main(struct efx_nic *efx)
 	unsigned int bar_size = resource_size(&efx->pci_dev->resource[efx->mem_bar]);
 	struct net_device *net_dev = efx->net_dev;
 	struct ef100_nic_data *nic_data;
+	char fw_version[32];
 	int i, rc;
 
 	if (WARN_ON(bar_size == 0))
@@ -562,6 +593,15 @@ static int ef100_probe_main(struct efx_nic *efx)
 		goto fail;
 	efx->port_num = rc;
 
+	efx_mcdi_print_fwver(efx, fw_version, sizeof(fw_version));
+	netif_dbg(efx, drv, efx->net_dev, "Firmware version %s\n", fw_version);
+
+	if (compare_versions(fw_version, "1.1.0.1000") < 0) {
+		netif_info(efx, drv, efx->net_dev, "Firmware uses old event descriptors\n");
+		rc = -EINVAL;
+		goto fail;
+	}
+
 	rc = ef100_phy_probe(efx);
 	if (rc)
 		goto fail;


  reply	other threads:[~2020-07-31 12:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 12:55 [PATCH v2 net-next 00/11] sfc: driver for EF100 family NICs, part 2 Edward Cree
2020-07-31 12:58 ` Edward Cree [this message]
2020-07-31 12:58 ` [PATCH v2 net-next 02/11] sfc_ef100: fail the probe if NIC uses unsol_ev credits Edward Cree
2020-07-31 12:58 ` [PATCH v2 net-next 03/11] sfc_ef100: read Design Parameters at probe time Edward Cree
2020-07-31 20:18   ` Jakub Kicinski
2020-08-03 14:33     ` Edward Cree
2020-08-03 21:54       ` Jakub Kicinski
2020-07-31 12:59 ` [PATCH v2 net-next 04/11] sfc_ef100: TX path for EF100 NICs Edward Cree
2020-07-31 19:39   ` Jakub Kicinski
2020-08-03 14:36     ` Edward Cree
2020-07-31 12:59 ` [PATCH v2 net-next 05/11] sfc_ef100: RX filter table management and related gubbins Edward Cree
2020-07-31 12:59 ` [PATCH v2 net-next 06/11] sfc_ef100: RX path for EF100 Edward Cree
2020-07-31 13:00 ` [PATCH v2 net-next 07/11] sfc_ef100: plumb in fini_dmaq Edward Cree
2020-07-31 13:00 ` [PATCH v2 net-next 08/11] sfc_ef100: statistics gathering Edward Cree
2020-07-31 20:27   ` Jakub Kicinski
2020-07-31 13:00 ` [PATCH v2 net-next 09/11] sfc_ef100: functions for selftests Edward Cree
2020-07-31 13:01 ` [PATCH v2 net-next 10/11] sfc_ef100: read pf_index at probe time Edward Cree
2020-07-31 13:01 ` [PATCH v2 net-next 11/11] sfc_ef100: add nic-type for VFs, and bind to them Edward Cree

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01fb1600-3f84-c1a8-ef02-68e32fb9402d@solarflare.com \
    --to=ecree@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.