Skip to content

Add ability to flash modules' firmware

Danielle Ratson linux-doc lkml netdev 9 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest9 patches 0 repliesApplied 9/9
  2. v79 patches 15 repliesSuperseded
  3. v69 patches 3 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v510 patches16 repliesSuperseded
v410 patches3 repliesSuperseded
v310 patches5 repliesSuperseded
v2 posting 2/210 patches2 repliesSuperseded
v2 RFC posting 1/29 patches0 repliesSuperseded
v1 RFC9 patches34 repliesSuperseded

Changes in v8 from the cover letter

Patch #7:
* In the ethtool_cmis_wait_for_cond() evaluate the condition once more to decide if the error code should be -ETIMEDOUT or something else.
* s/netdev_err/netdev_err_once.

Patches in v8 All 9 applied

#Subject and filesSizeRepliesApplied
1/9ethtool: Add ethtool operation to write to a transceiver module EEPROMinclude/linux/ethtool.h+12 -80 repliesApplied
2/9mlxsw: Implement ethtool operation to write to a transceiver module EEPROMdrivers/net/ethernet/mellanox/mlxsw/core_env.c drivers/net/ethernet/mellanox/mlxsw/core_env.h drivers/net/ethernet/mellanox/mlxsw/minimal.c +1 more+93 -00 repliesApplied
3/9ethtool: Add an interface for flashing transceiver modules' firmwareDocumentation/netlink/specs/ethtool.yaml Documentation/networking/ethtool-netlink.rst include/uapi/linux/ethtool.h +2 more+164 -10 repliesApplied
4/9ethtool: Add flashing transceiver modules' firmware notifications abilitynet/ethtool/module.c net/ethtool/module_fw.h net/ethtool/netlink.c +1 more+154 -00 repliesApplied
5/9ethtool: Veto some operations during firmware flashing processinclude/linux/netdevice.h net/ethtool/eeprom.c net/ethtool/ioctl.c +1 more+33 -10 repliesApplied
6/9net: sfp: Add more extended compliance codesinclude/linux/sfp.h+6 -00 repliesApplied
7/9ethtool: cmis_cdb: Add a layer for supporting CDB commandsnet/ethtool/Makefile net/ethtool/cmis.h net/ethtool/cmis_cdb.c +1 more+730 -10 repliesApplied
8/9ethtool: cmis_fw_update: add a layer for supporting firmware update using CDBnet/ethtool/Makefile net/ethtool/cmis.h net/ethtool/cmis_fw_update.c +1 more+438 -10 repliesApplied
9/9ethtool: Add ability to flash transceiver modules' firmwarenet/ethtool/module.c net/ethtool/module_fw.h net/ethtool/netlink.c +1 more+334 -00 repliesApplied

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by.

PatchPetr MachataAndrew LunnRussell King (Oracle)
1/9R-b R-b
2/9R-b R-b
3/9R-b R-b
4/9R-b R-b
5/9R-b R-b
6/9R-b R-b R-b
7/9R-b
8/9R-b
9/9R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v8 thread

Cover letter [PATCH net-next v8 0/9] Add ability to flash modules' firmware

CMIS compliant modules such as QSFP-DD might be running a firmware that can be updated in a vendor-neutral way by exchanging messages between the host and the module as described in section 7.2.2 of revision 4.0 of the CMIS standard.

According to the CMIS standard, the firmware update process is done using a CDB commands sequence.

CDB (Command Data Block Message Communication) reads and writes are performed on memory map pages 9Fh-AFh according to the CMIS standard, section 8.12 of revision 4.0.

Add a pair of new ethtool messages that allow:

* User space to trigger firmware update of transceiver modules

* The kernel to notify user space about the progress of the process

The user interface is designed to be asynchronous in order to avoid RTNL being held for too long and to allow several modules to be updated simultaneously. The interface is designed with CMIS compliant modules in mind, but kept generic enough to accommodate future use cases, if these arise.

The kernel interface that will implement the firmware update using CDB command will include 2 layers that will be added under ethtool:

* The upper layer that will be triggered from the module layer, is cmis_ fw_update.
* The lower one is cmis_cdb.

In the future there might be more operations to implement using CDB commands. Therefore, the idea is to keep the cmis_cdb interface clean and the cmis_fw_update specific to the cdb commands handling it.

The communication between the kernel and the driver will be done using two ethtool operations that enable reading and writing the transceiver module EEPROM.
The operation ethtool_ops::get_module_eeprom_by_page, that is already implemented, will be used for reading from the EEPROM the CDB reply, e.g. reading module setting, state, etc.
The operation ethtool_ops::set_module_eeprom_by_page, that is added in the current patchset, will be used for writing to the EEPROM the CDB command such as start firmware image, run firmware image, etc.

Therefore in order for a driver to implement module flashing, that driver needs to implement the two functions mentioned above.

Patchset overview:
Patch #1-#2: Implement the EEPROM writing in mlxsw. Patch #3: Define the interface between the kernel and user space. Patch #4: Add ability to notify the flashing firmware progress. Patch #5: Veto operations during flashing.
Patch #6: Add extended compliance codes.
Patch #7: Add the cdb layer.
Patch #8: Add the fw_update layer.
Patch #9: Add ability to flash transceiver modules' firmware.

v8:
Patch #7:
* In the ethtool_cmis_wait_for_cond() evaluate the condition once more to decide if the error code should be -ETIMEDOUT or something else.
* s/netdev_err/netdev_err_once.

v7:
Patch #4:
* Return -ENOMEM instead of PTR_ERR(attr) on ethnl_module_fw_flash_ntf_put_err().
Patch #9:
* Fix Warning for not unlocking the spin_lock in the error flow on module_flash_fw_work_list_add().
* Avoid the fall-through on ethnl_sock_priv_destroy().

v6:
* Squash some of the last patch to patch #5 and patch #9.
Patch #3:
* Add paragraph in .rst file.
Patch #4:
* Reserve '1' more place on SKB for NUL terminator in
the error message string.
* Add more prints on error flow, re-write the printing function and add ethnl_module_fw_flash_ntf_put_err().
* Change the communication method so notification will be sent in unicast instead of multicast.
* Add new 'struct ethnl_module_fw_flash_ntf_params' that holds the relevant info for unicast communication and use it to send notification to the specific socket.
* s/nla_put_u64_64bit/nla_put_uint/
Patch #7:
* In ethtool_cmis_cdb_init(), Use 'const' for the 'params' parameter.
Patch #8:
* Add a list field to struct ethtool_module_fw_flash for module_fw_flash_work_list that will be presented in the next patch.
* Move ethtool_cmis_fw_update() cleaning to a new function that will be represented in the next patch.
* Move some of the fields in struct ethtool_module_fw_flash to a separate struct, so ethtool_cmis_fw_update() will get only the relevant parameters for it.
* Edit the relevant functions to get the relevant params for them.
* s/CMIS_MODULE_READY_MAX_DURATION_USEC/CMIS_MODULE_READY_MAX_DURATION_MSEC
Patch #9:
* Add a paragraph in the commit message.
* Rename labels in module_flash_fw_schedule().
* Add info to genl_sk_priv_*() and implement the relevant callbacks, in order to handle properly a scenario of closing the socket from user space before the work item was ended.
* Add a list the holds all the ethtool_module_fw_flash struct that corresponds to the in progress work items.
* Add a new enum for the socket types.
* Use both above to identify a flashing socket, add it to the list and when closing socket affect only the flashing type.
* Create a new function that will get the work item instead of ethtool_cmis_fw_update().
* Edit the relevant functions to get the relevant params for them.
* The new function will call the old ethtool_cmis_fw_update(), and do the cleaning, so the existence of the list should be completely isolated in module.c.

Danielle Ratson (7):
ethtool: Add an interface for flashing transceiver modules' firmware
ethtool: Add flashing transceiver modules' firmware notifications
ability
ethtool: Veto some operations during firmware flashing process
net: sfp: Add more extended compliance codes
ethtool: cmis_cdb: Add a layer for supporting CDB commands
ethtool: cmis_fw_update: add a layer for supporting firmware update
using CDB
ethtool: Add ability to flash transceiver modules' firmware

Ido Schimmel (2):
ethtool: Add ethtool operation to write to a transceiver module EEPROM
mlxsw: Implement ethtool operation to write to a transceiver module
EEPROM

 Documentation/netlink/specs/ethtool.yaml      |  55 ++
 Documentation/networking/ethtool-netlink.rst  |  70 ++
 .../net/ethernet/mellanox/mlxsw/core_env.c    |  57 ++
 .../net/ethernet/mellanox/mlxsw/core_env.h    |   6 +
 drivers/net/ethernet/mellanox/mlxsw/minimal.c |  15 +
 .../mellanox/mlxsw/spectrum_ethtool.c         |  15 +
 include/linux/ethtool.h                       |  20 +-
 include/linux/netdevice.h                     |   4 +-
 include/linux/sfp.h                           |   6 +
 include/uapi/linux/ethtool.h                  |  18 +
 include/uapi/linux/ethtool_netlink.h          |  19 +
 net/ethtool/Makefile                          |   2 +-
 net/ethtool/cmis.h                            | 124 ++++
 net/ethtool/cmis_cdb.c                        | 602 ++++++++++++++++++
 net/ethtool/cmis_fw_update.c                  | 399 ++++++++++++
 net/ethtool/eeprom.c                          |   6 +
 net/ethtool/ioctl.c                           |  12 +
 net/ethtool/module.c                          | 394 ++++++++++++
 net/ethtool/module_fw.h                       |  75 +++
 net/ethtool/netlink.c                         |  56 ++
 net/ethtool/netlink.h                         |  16 +
 tools/net/ynl/Makefile.deps                   |   3 +-
 22 files changed, 1963 insertions(+), 11 deletions(-)
 create mode 100644 net/ethtool/cmis.h
 create mode 100644 net/ethtool/cmis_cdb.c
 create mode 100644 net/ethtool/cmis_fw_update.c
 create mode 100644 net/ethtool/module_fw.h
Signature · 1 line
2.45.0