Skip to content

Commit be1d2a1

Browse files
committed
Merge branch 'sfc-support-devlink-flash'
Edward Cree says: ==================== sfc: support devlink flash Allow upgrading device firmware on Solarflare NICs through standard tools. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents f4b87ed + 5ea73bf commit be1d2a1

File tree

12 files changed

+804
-27
lines changed

12 files changed

+804
-27
lines changed

Documentation/networking/devlink/sfc.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sfc devlink support
55
===================
66

77
This document describes the devlink features implemented by the ``sfc``
8-
device driver for the ef100 device.
8+
device driver for the ef10 and ef100 devices.
99

1010
Info versions
1111
=============
@@ -18,6 +18,10 @@ The ``sfc`` driver reports the following versions
1818
* - Name
1919
- Type
2020
- Description
21+
* - ``fw.bundle_id``
22+
- stored
23+
- Version of the firmware "bundle" image that was last used to update
24+
multiple components.
2125
* - ``fw.mgmt.suc``
2226
- running
2327
- For boards where the management function is split between multiple
@@ -55,3 +59,13 @@ The ``sfc`` driver reports the following versions
5559
* - ``fw.uefi``
5660
- running
5761
- UEFI driver version (No UNDI support).
62+
63+
Flash Update
64+
============
65+
66+
The ``sfc`` driver implements support for flash update using the
67+
``devlink-flash`` interface. It supports updating the device flash using a
68+
combined flash image ("bundle") that contains multiple components (on ef10,
69+
typically ``fw.mgmt``, ``fw.app``, ``fw.exprom`` and ``fw.uefi``).
70+
71+
The driver does not support any overwrite mask flags.

drivers/net/ethernet/sfc/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ config SFC_MTD
3838
default y
3939
help
4040
This exposes the on-board flash and/or EEPROM as MTD devices
41-
(e.g. /dev/mtd1). This is required to update the firmware or
42-
the boot configuration under Linux.
41+
(e.g. /dev/mtd1). This is required to update the boot
42+
configuration under Linux, or use some older userland tools to
43+
update the firmware.
4344
config SFC_MCDI_MON
4445
bool "Solarflare SFC9100-family hwmon support"
4546
depends on SFC && HWMON && !(SFC=y && HWMON=m)

drivers/net/ethernet/sfc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \
77
mcdi_functions.o mcdi_filters.o mcdi_mon.o \
88
ef100.o ef100_nic.o ef100_netdev.o \
99
ef100_ethtool.o ef100_rx.o ef100_tx.o \
10-
efx_devlink.o
10+
efx_devlink.o efx_reflash.o
1111
sfc-$(CONFIG_SFC_MTD) += mtd.o
1212
sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \
1313
mae.o tc.o tc_bindings.o tc_counters.o \

drivers/net/ethernet/sfc/ef10.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,7 +3501,7 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
35013501
MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN);
35023502
MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_METADATA_OUT_LENMAX);
35033503
const struct efx_ef10_nvram_type_info *info;
3504-
size_t size, erase_size, outlen;
3504+
size_t size, erase_size, write_size, outlen;
35053505
int type_idx = 0;
35063506
bool protected;
35073507
int rc;
@@ -3516,7 +3516,8 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
35163516
if (info->port != efx_port_num(efx))
35173517
return -ENODEV;
35183518

3519-
rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &protected);
3519+
rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &write_size,
3520+
&protected);
35203521
if (rc)
35213522
return rc;
35223523
if (protected &&
@@ -3561,6 +3562,8 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
35613562
if (!erase_size)
35623563
part->common.mtd.flags |= MTD_NO_ERASE;
35633564

3565+
part->common.mtd.writesize = write_size;
3566+
35643567
return 0;
35653568
}
35663569

drivers/net/ethernet/sfc/efx_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev)
10031003
INIT_LIST_HEAD(&efx->vf_reps);
10041004
INIT_WORK(&efx->mac_work, efx_mac_work);
10051005
init_waitqueue_head(&efx->flush_wq);
1006+
mutex_init(&efx->reflash_mutex);
10061007

10071008
efx->tx_queues_per_channel = 1;
10081009
efx->rxq_entries = EFX_DEFAULT_DMAQ_SIZE;

drivers/net/ethernet/sfc/efx_devlink.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "mae.h"
2020
#include "ef100_rep.h"
2121
#endif
22+
#include "efx_reflash.h"
2223

2324
struct efx_devlink {
2425
struct efx_nic *efx;
@@ -615,7 +616,19 @@ static int efx_devlink_info_get(struct devlink *devlink,
615616
return 0;
616617
}
617618

619+
static int efx_devlink_flash_update(struct devlink *devlink,
620+
struct devlink_flash_update_params *params,
621+
struct netlink_ext_ack *extack)
622+
{
623+
struct efx_devlink *devlink_private = devlink_priv(devlink);
624+
struct efx_nic *efx = devlink_private->efx;
625+
626+
return efx_reflash_flash_firmware(efx, params->fw, extack);
627+
}
628+
618629
static const struct devlink_ops sfc_devlink_ops = {
630+
.supported_flash_update_params = 0,
631+
.flash_update = efx_devlink_flash_update,
619632
.info_get = efx_devlink_info_get,
620633
};
621634

0 commit comments

Comments
 (0)