diff mbox series

[v2,net-next,3/3] sfc: support X4 devlink flash

Message ID 9a72a74002a7819c780b0a18ce9294c9d4e1db12.1742493017.git.ecree.xilinx@gmail.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series sfc: devlink flash for X4 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 83 exceeds 80 columns WARNING: line length of 85 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 58 this patch: 58
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2025-03-21--18-00 (tests: 896)

Commit Message

edward.cree@amd.com March 20, 2025, 5:57 p.m. UTC
From: Edward Cree <ecree.xilinx@gmail.com>

Unlike X2 and EF100, we do not attempt to parse the firmware file to
 find an image within it; we simply hand the entire file to the MC,
 which is responsible for understanding any container formats we might
 use and validating that the firmware file is applicable to this NIC.

Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
---
 drivers/net/ethernet/sfc/ef10.c        |  1 +
 drivers/net/ethernet/sfc/efx_reflash.c | 52 +++++++++++++++-----------
 drivers/net/ethernet/sfc/net_driver.h  |  3 ++
 3 files changed, 34 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 47d78abecf30..47349c148c0c 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -4419,6 +4419,7 @@  const struct efx_nic_type efx_x4_nic_type = {
 	.can_rx_scatter = true,
 	.always_rx_scatter = true,
 	.option_descriptors = true,
+	.flash_auto_partition = true,
 	.min_interrupt_mode = EFX_INT_MODE_MSIX,
 	.timer_period_max = 1 << ERF_DD_EVQ_IND_TIMER_VAL_WIDTH,
 	.offload_features = EF10_OFFLOAD_FEATURES,
diff --git a/drivers/net/ethernet/sfc/efx_reflash.c b/drivers/net/ethernet/sfc/efx_reflash.c
index ddc53740f098..b12e95f1c80a 100644
--- a/drivers/net/ethernet/sfc/efx_reflash.c
+++ b/drivers/net/ethernet/sfc/efx_reflash.c
@@ -407,31 +407,40 @@  int efx_reflash_flash_firmware(struct efx_nic *efx, const struct firmware *fw,
 		return -EOPNOTSUPP;
 	}
 
-	devlink_flash_update_status_notify(devlink, "Checking update", NULL, 0, 0);
+	mutex_lock(&efx->reflash_mutex);
 
-	rc = efx_reflash_parse_firmware_data(fw, &type, &data_subtype, &data,
-					     &data_size);
-	if (rc) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "Firmware image validation check failed");
-		goto out;
-	}
+	devlink_flash_update_status_notify(devlink, "Checking update", NULL, 0, 0);
 
-	mutex_lock(&efx->reflash_mutex);
+	if (efx->type->flash_auto_partition) {
+		/* NIC wants entire FW file including headers;
+		 * FW will validate 'subtype' if there is one
+		 */
+		type = NVRAM_PARTITION_TYPE_AUTO;
+		data = fw->data;
+		data_size = fw->size;
+	} else {
+		rc = efx_reflash_parse_firmware_data(fw, &type, &data_subtype, &data,
+						     &data_size);
+		if (rc) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "Firmware image validation check failed");
+			goto out_unlock;
+		}
 
-	rc = efx_mcdi_nvram_metadata(efx, type, &subtype, NULL, NULL, 0);
-	if (rc) {
-		NL_SET_ERR_MSG_FMT_MOD(extack,
-				       "Metadata query for NVRAM partition %#x failed",
-				       type);
-		goto out_unlock;
-	}
+		rc = efx_mcdi_nvram_metadata(efx, type, &subtype, NULL, NULL, 0);
+		if (rc) {
+			NL_SET_ERR_MSG_FMT_MOD(extack,
+					       "Metadata query for NVRAM partition %#x failed",
+					       type);
+			goto out_unlock;
+		}
 
-	if (subtype != data_subtype) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "Firmware image is not appropriate for this adapter");
-		rc = -EINVAL;
-		goto out_unlock;
+		if (subtype != data_subtype) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "Firmware image is not appropriate for this adapter");
+			rc = -EINVAL;
+			goto out_unlock;
+		}
 	}
 
 	rc = efx_mcdi_nvram_info(efx, type, &size, &erase_align, &write_align,
@@ -506,7 +515,6 @@  int efx_reflash_flash_firmware(struct efx_nic *efx, const struct firmware *fw,
 		rc = efx_mcdi_nvram_update_finish_polled(efx, type);
 out_unlock:
 	mutex_unlock(&efx->reflash_mutex);
-out:
 	devlink_flash_update_status_notify(devlink, rc ? "Update failed" :
 							 "Update complete",
 					   NULL, 0, 0);
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index 6912661b5a3d..5c0f306fb019 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -1381,6 +1381,8 @@  struct efx_udp_tunnel {
  * @can_rx_scatter: NIC is able to scatter packets to multiple buffers
  * @always_rx_scatter: NIC will always scatter packets to multiple buffers
  * @option_descriptors: NIC supports TX option descriptors
+ * @flash_auto_partition: firmware flash uses AUTO partition, driver does
+ *	not need to perform image parsing
  * @min_interrupt_mode: Lowest capability interrupt mode supported
  *	from &enum efx_int_mode.
  * @timer_period_max: Maximum period of interrupt timer (in ticks)
@@ -1557,6 +1559,7 @@  struct efx_nic_type {
 	bool can_rx_scatter;
 	bool always_rx_scatter;
 	bool option_descriptors;
+	bool flash_auto_partition;
 	unsigned int min_interrupt_mode;
 	unsigned int timer_period_max;
 	netdev_features_t offload_features;