Skip to content

Commit 5726a15

Browse files
Edward Creekuba-moo
Edward Cree
authored andcommitted
sfc: support X4 devlink flash
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 <[email protected]> Link: https://patch.msgid.link/9a72a74002a7819c780b0a18ce9294c9d4e1db12.1742493017.git.ecree.xilinx@gmail.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 25d0c8e commit 5726a15

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4419,6 +4419,7 @@ const struct efx_nic_type efx_x4_nic_type = {
44194419
.can_rx_scatter = true,
44204420
.always_rx_scatter = true,
44214421
.option_descriptors = true,
4422+
.flash_auto_partition = true,
44224423
.min_interrupt_mode = EFX_INT_MODE_MSIX,
44234424
.timer_period_max = 1 << ERF_DD_EVQ_IND_TIMER_VAL_WIDTH,
44244425
.offload_features = EF10_OFFLOAD_FEATURES,

drivers/net/ethernet/sfc/efx_reflash.c

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -407,31 +407,40 @@ int efx_reflash_flash_firmware(struct efx_nic *efx, const struct firmware *fw,
407407
return -EOPNOTSUPP;
408408
}
409409

410-
devlink_flash_update_status_notify(devlink, "Checking update", NULL, 0, 0);
410+
mutex_lock(&efx->reflash_mutex);
411411

412-
rc = efx_reflash_parse_firmware_data(fw, &type, &data_subtype, &data,
413-
&data_size);
414-
if (rc) {
415-
NL_SET_ERR_MSG_MOD(extack,
416-
"Firmware image validation check failed");
417-
goto out;
418-
}
412+
devlink_flash_update_status_notify(devlink, "Checking update", NULL, 0, 0);
419413

420-
mutex_lock(&efx->reflash_mutex);
414+
if (efx->type->flash_auto_partition) {
415+
/* NIC wants entire FW file including headers;
416+
* FW will validate 'subtype' if there is one
417+
*/
418+
type = NVRAM_PARTITION_TYPE_AUTO;
419+
data = fw->data;
420+
data_size = fw->size;
421+
} else {
422+
rc = efx_reflash_parse_firmware_data(fw, &type, &data_subtype, &data,
423+
&data_size);
424+
if (rc) {
425+
NL_SET_ERR_MSG_MOD(extack,
426+
"Firmware image validation check failed");
427+
goto out_unlock;
428+
}
421429

422-
rc = efx_mcdi_nvram_metadata(efx, type, &subtype, NULL, NULL, 0);
423-
if (rc) {
424-
NL_SET_ERR_MSG_FMT_MOD(extack,
425-
"Metadata query for NVRAM partition %#x failed",
426-
type);
427-
goto out_unlock;
428-
}
430+
rc = efx_mcdi_nvram_metadata(efx, type, &subtype, NULL, NULL, 0);
431+
if (rc) {
432+
NL_SET_ERR_MSG_FMT_MOD(extack,
433+
"Metadata query for NVRAM partition %#x failed",
434+
type);
435+
goto out_unlock;
436+
}
429437

430-
if (subtype != data_subtype) {
431-
NL_SET_ERR_MSG_MOD(extack,
432-
"Firmware image is not appropriate for this adapter");
433-
rc = -EINVAL;
434-
goto out_unlock;
438+
if (subtype != data_subtype) {
439+
NL_SET_ERR_MSG_MOD(extack,
440+
"Firmware image is not appropriate for this adapter");
441+
rc = -EINVAL;
442+
goto out_unlock;
443+
}
435444
}
436445

437446
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,
506515
rc = efx_mcdi_nvram_update_finish_polled(efx, type);
507516
out_unlock:
508517
mutex_unlock(&efx->reflash_mutex);
509-
out:
510518
devlink_flash_update_status_notify(devlink, rc ? "Update failed" :
511519
"Update complete",
512520
NULL, 0, 0);

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,8 @@ struct efx_udp_tunnel {
13811381
* @can_rx_scatter: NIC is able to scatter packets to multiple buffers
13821382
* @always_rx_scatter: NIC will always scatter packets to multiple buffers
13831383
* @option_descriptors: NIC supports TX option descriptors
1384+
* @flash_auto_partition: firmware flash uses AUTO partition, driver does
1385+
* not need to perform image parsing
13841386
* @min_interrupt_mode: Lowest capability interrupt mode supported
13851387
* from &enum efx_int_mode.
13861388
* @timer_period_max: Maximum period of interrupt timer (in ticks)
@@ -1557,6 +1559,7 @@ struct efx_nic_type {
15571559
bool can_rx_scatter;
15581560
bool always_rx_scatter;
15591561
bool option_descriptors;
1562+
bool flash_auto_partition;
15601563
unsigned int min_interrupt_mode;
15611564
unsigned int timer_period_max;
15621565
netdev_features_t offload_features;

0 commit comments

Comments
 (0)