Skip to contentSkip to conversation

devlink: expand the devlink-info documentation

PATCH Superseded Jakub Kicinski 2 participants 3 messages Mar 24, 2020

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/1 devlink: expand the devlink-info documentation

We are having multiple review cycles with all vendors trying to implement devlink-info. Let's expand the documentation with more information about what's implemented and motivation behind this interface in an attempt to make the implementations easier.

Describe what each info section is supposed to contain, and make some references to other HW interfaces (PCI caps).

Document how firmware management is expected to look, to make it clear how devlink-info and devlink-flash work in concert.

Name some future work.

v2: - improve wording

---
 .../networking/devlink/devlink-flash.rst      |  93 ++++++++++++
 .../networking/devlink/devlink-info.rst       | 133 +++++++++++++++---
 .../networking/devlink/devlink-params.rst     |   2 +
 Documentation/networking/devlink/index.rst    |   1 +
 4 files changed, 213 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/networking/devlink/devlink-flash.rst
Documentation/networking/devlink/devlink-flash.rst new file +93 -0
new file mode 100644
index 000000000000..40a87c0222cb
@@ -0,0 +1,93 @@
+.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+.. _devlink_flash:
+
+=============
+Devlink Flash
+=============
+
+The ``devlink-flash`` API allows updating device firmware. It replaces the
+older ``ethtool-flash`` mechanism, and doesn't require taking any
+networking locks in the kernel to perform the flash update. Example use::
+
+  $ devlink dev flash pci/0000:05:00.0 file flash-boot.bin
+
+Note that the file name is a path relative to the firmware loading path
+(usually ``/lib/firmware/``). Drivers may send status updates to inform
+user space about the progress of the update operation.
+
+Firmware Loading
+================
+
+Devices which require firmware to operate usually store it in non-volatile
+memory on the board, e.g. flash. Some devices store only basic firmware on
+the board, and the driver loads the rest from disk during probing.
+``devlink-info`` allows users to query firmware information (loaded
+components and versions).
+
+In other cases the device can both store the image on the board, load from
+disk, or automatically flash a new image from disk. The ``fw_load_policy``
+devlink parameter can be used to control this behavior
+(:ref:`Documentation/networking/devlink/devlink-params.rst <devlink_params_generic>`).
+
+On-disk firmware files are usually stored in ``/lib/firmware/``.
+
+Firmware Version Management
+===========================
+
+Drivers are expected to implement ``devlink-flash`` and ``devlink-info``
+functionality, which together allow for implementing vendor-independent
+automated firmware update facilities.
+
+``devlink-info`` exposes the ``driver`` name and three version groups
+(``fixed``, ``running``, ``stored``).
+
+The ``driver`` attribute and ``fixed`` group identify the specific device
+design, e.g. for looking up applicable firmware updates. This is why
+``serial_number`` is not part of the ``fixed`` versions (even though it
+is fixed) - ``fixed`` versions should identify the design, not a single
+device.
+
+``running`` and ``stored`` firmware versions identify the firmware running
+on the device, and firmware which will be activated after reboot or device
+reset.
+
+The firmware update agent is supposed to be able to follow this simple
+algorithm to update firmware contents, regardless of the device vendor:
+
+.. code-block:: sh
+
+  # Get unique HW design identifier
+  $hw_id = devlink-dev-info['fixed']
+
+  # Find out which FW flash we want to use for this NIC
+  $want_flash_vers = some-db-backed.lookup($hw_id, 'flash')
+
+  # Update flash if necessary
+  if $want_flash_vers != devlink-dev-info['stored']:
+      $file = some-db-backed.download($hw_id, 'flash')
+      devlink-dev-flash($file)
+
+  # Find out the expected overall firmware versions
+  $want_fw_vers = some-db-backed.lookup($hw_id, 'all')
+
+  # Update on-disk file if necessary
+  if $want_fw_vers != devlink-dev-info['running']:
+      $file = some-db-backed.download($hw_id, 'disk')
+      write($file, '/lib/firmware/')
+
+  # Try device reset, if available
+  if $want_fw_vers != devlink-dev-info['running']:
+     devlink-reset()
+
+  # Reboot, if reset wasn't enough
+  if $want_fw_vers != devlink-dev-info['running']:
+     reboot()
+
+Note that each reference to ``devlink-dev-info`` in this pseudo-code
+is expected to fetch up-to-date information from the kernel.
+
+For the convenience of identifying firmware files some vendors add
+``bundle_id`` information to the firmware versions. This meta-version covers
+multiple per-component versions and can be used e.g. in firmware file names
+(all component versions could get rather long.)
Documentation/networking/devlink/devlink-info.rst +117 -16

168 lines not on this page · raw message

Documentation/networking/devlink/devlink-params.rst +2 -0
index da2f85c0fa21..d075fd090b3d 100644
@@ -41,6 +41,8 @@ In order for ``driverinit`` parameters to take effect, the driver must
 support reloading via the ``devlink-reload`` command. This command will
 request a reload of the device driver.
 
+.. _devlink_params_generic:
+
 Generic configuration parameters
 ================================
 The following is a list of generic configuration parameters that drivers may
Documentation/networking/devlink/index.rst +1 -0
index 087ff54d53fc..55ee74e52d97 100644
@@ -16,6 +16,7 @@ general.
    devlink-dpipe
    devlink-health
    devlink-info
+   devlink-flash
    devlink-params
    devlink-region
    devlink-resource
Signature · 1 line
2.25.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Jakub Kicinski

We are having multiple review cycles with all vendors trying to implement devlink-info. Let's expand the documentation with more information about what's implemented and motivation behind this interface in an attempt to make the implementations easier.

Describe what each info section is supposed to contain, and make some references to other HW interfaces (PCI caps).

Quoted 8 lines

Document how firmware management is expected to look, to make it clear how devlink-info and devlink-flash work in concert.

Name some future work.

v2: - improve wording

Hi Jakub,

One minor edit below, and

Quoted 15 lines
---
 .../networking/devlink/devlink-flash.rst      |  93 ++++++++++++
 .../networking/devlink/devlink-info.rst       | 133 +++++++++++++++---
 .../networking/devlink/devlink-params.rst     |   2 +
 Documentation/networking/devlink/index.rst    |   1 +
 4 files changed, 213 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/networking/devlink/devlink-flash.rst
Documentation/networking/devlink/devlink-info.rst +0 -0
index 70981dd1b981..8d47289a5844 100644
@@ -5,34 +5,119 @@ Devlink Info

[snip]

Documentation/networking/devlink/devlink-info.rst Devlink Info · line 91

Quoted 7 lines

Generic Versions
================

It is expected that drivers use the following generic names for exporting

Documentation/networking/devlink/devlink-info.rst +1 -2
-version information. Other information may be exposed using driver-specific
-names, but these should be documented in the driver-specific file.
+version information. If a generic name for a given component doesn't exist, yet,

exist yet,

Documentation/networking/devlink/devlink-info.rst Devlink Info · line 96

Quoted 5 lines
Documentation/networking/devlink/devlink-info.rst +5 -0
+driver authors should consult existing driver-specific versions and attempt
+reuse. As last resort, if a component is truly unique, using driver-specific
+names is allowed, but these should be documented in the driver-specific file.
+
+All versions should try to use the following terminology:

cheers.

Signature · 1 line
~Randy
author maintainer
#2 lore raw
Quoted 16 lines · On Mon, 23 Mar 2020 22:33:26 -0700 Randy Dunlap wrote:
Quoted 15 lines · Jakub Kicinski

We are having multiple review cycles with all vendors trying to implement devlink-info. Let's expand the documentation with more information about what's implemented and motivation behind this interface in an attempt to make the implementations easier.

Describe what each info section is supposed to contain, and make some references to other HW interfaces (PCI caps).

Document how firmware management is expected to look, to make it clear how devlink-info and devlink-flash work in concert.

Name some future work.

v2: - improve wording

Quoted 7 lines
Quoted 1 line

Hi Jakub,

One minor edit below, and

Will fix, thanks!

Quoted 15 lines

Documentation/networking/devlink/devlink-info.rst Devlink Info · line 91

Quoted 7 lines

Generic Versions
================

It is expected that drivers use the following generic names for exporting

Documentation/networking/devlink/devlink-info.rst +1 -2
-version information. Other information may be exposed using driver-specific
-names, but these should be documented in the driver-specific file.
+version information. If a generic name for a given component doesn't exist, yet,  

exist yet,

Quoted 5 lines
Documentation/networking/devlink/devlink-info.rst +5 -0
+driver authors should consult existing driver-specific versions and attempt
+reuse. As last resort, if a component is truly unique, using driver-specific
+names is allowed, but these should be documented in the driver-specific file.
+
+All versions should try to use the following terminology: