devlink: expand the devlink-info documentation
Subsystems (4)
Jakub Kicinski
maintainerPATCH 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.
--- .../networking/devlink/devlink-flash.rst | 88 ++++++++++++ .../networking/devlink/devlink-info.rst | 132 +++++++++++++++--- .../networking/devlink/devlink-params.rst | 2 + Documentation/networking/devlink/index.rst | 1 + 4 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 Documentation/networking/devlink/devlink-flash.rst
Documentation/networking/devlink/devlink-flash.rst new file +88 -0
@@ -0,0 +1,88 @@ +.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +.. _devlink_flash: + +============= +Devlink Flash +============= + +The ``devlink-flash`` 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 driver loads the rest from disk during probing. +``devlink-info`` allows users to query firmware information (loaded +components and versions). + +In other cases device can both store the image on the board, load from +disk, or automatically flash a new image from disk. ``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``). + +``driver`` 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/') + + # Reboot if necessary + 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 +116 -16
167 lines not on this page · raw message
Documentation/networking/devlink/devlink-params.rst +2 -0
@@ -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
@@ -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
Quoted 5 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.
Quoted 8 lines
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.>
Signed-off-by Jakub Kicinski <[email protected]>
This looks great! It's nice to see some of the expectations defined clearly.
Having a document for the devlink-flash.rst is also a nice improvement.
Thanks,
Jake
Quoted 302 lines
--- .../networking/devlink/devlink-flash.rst | 88 ++++++++++++ .../networking/devlink/devlink-info.rst | 132 +++++++++++++++--- .../networking/devlink/devlink-params.rst | 2 + Documentation/networking/devlink/index.rst | 1 + 4 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 Documentation/networking/devlink/devlink-flash.rstDocumentation/networking/devlink/devlink-flash.rst new file +88
-0@@ -0,0 +1,88 @@ +.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +.. _devlink_flash: + +============= +Devlink Flash +============= + +The ``devlink-flash`` 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 driver loads the rest from disk during probing. +``devlink-info`` allows users to query firmware information (loaded +components and versions). + +In other cases device can both store the image on the board, load from +disk, or automatically flash a new image from disk. ``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``). + +``driver`` 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/') + + # Reboot if necessary + 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 +116
-16@@ -5,34 +5,118 @@ Devlink Info ============ The ``devlink-info`` mechanism enables device drivers to report device -information in a generic fashion. It is extensible, and enables exporting -even device or driver specific information. +(hardware and firmware) information in a standard, extensible fashion. -devlink supports representing the following types of versions +The original motivation for the ``devlink-info`` API was twofold: -.. list-table:: List of version types + - making it possible to automate device and firmware management in a fleet + of machines in a vendor-independent fashion (see also + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`); + - name the per component FW versions (as opposed to the crowded ethtool + version string). + +``devlink-info`` supports reporting multiple types of objects. Reporting driver +versions is generally discouraged - here, and via any other Linux API. + +.. list-table:: List of top level info objects :widths: 5 95 - * - Type + * - Name - Description + * - ``driver`` + - Name of the currently used device driver, also available through sysfs. + + * - ``serial_number`` + - Serial number of the device. + + This is usually the serial number of the ASIC, also often available + in PCI config space of the device in the *Device Serial Number* + capability. + + The serial number should be unique per physical device. + Sometimes the serial number of the device is only 48 bits long (the + length of the Ethernet MAC address), and since PCI DSN is 64 bits long + devices pad or encode additional information into the serial number. + One example is adding port ID or PCI interface ID in the extra two bytes. + Drivers should make sure to strip or normalize any such padding + or interface ID, and report only the part of the serial number + which uniquely identify the hardware. In other words serial number + reported for two ports of the same device or on two hosts of + a multi-host device should be identical. + + .. note:: ``devlink-info`` API should be extended with a new field + if devices want to report board/product serial number (often + reported in PCI *Vital Product Data* capability). + * - ``fixed`` - - Represents fixed versions, which cannot change. For example, + - Group for hardware identifiers, and versions of components + which are not field-updatable. + + Versions in this section identify the device design. For example, component identifiers or the board version reported in the PCI VPD. + Data in ``devlink-info`` should be broken into smallest logical + components, e.g. PCI VPD may concatenate various information + to form the Part Number string, in ``devlink-info`` all parts + should be reported as separate items. + + This groups must not contain any frequently changing identifiers, + such as serial numbers. See + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>` + to understand why. + * - ``running`` - - Represents the version of the currently running component. For - example the running version of firmware. These versions generally - only update after a reboot. + - Group for information about currently running software/firmware. + These versions often only update after a reboot, sometimes device reset. + * - ``stored`` - - Represents the version of a component as stored, such as after a - flash update. Stored values should update to reflect changes in the - flash even if a reboot has not yet occurred. + - Group for software/firmware versions in device flash. + + Stored values must update to reflect changes in the flash even + if reboot has not yet occurred. If device is not capable of updating + ``stored`` versions when new software is flashed, it must not report + them. + +Each version can be reported at most once in each version group. Firmware +components stored on the flash should feature both in ``running`` and +``stored`` section, if device is capable of reporting ``stored`` versions +(see :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`). +In case software/firmware components are loaded from the disk (e.g. +``/lib/firmware``) only running version should be reported via the kernel API. Generic Versions ================ It is expected that drivers use the following generic names for exporting -version information. Other information may be exposed using driver-specific -names, but these should be documented in the driver-specific file. +version information. If generic name for given component doesn't exist, yet, +driver authors should consult existing driver-specific versions and attempt +reuse. As last resort, if 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: + +.. list-table:: List of common version suffixes + :widths: 10 90 + + * - Name + - Description + * - ``id``, ``revision`` + - Identifiers of designs and revision, mostly used for hardware versions. + + * - ``api`` + - Version of API between components. API items are usually of limited + value to the user, and can be inferred from other versions by the vendor, + so adding API versions is generally discouraged as noise. + + * - ``bundle_id`` + - Identifier of a distribution package which was flashed onto the device. + This is an attribute of a firmware package which covers multiple versions + for ease of managing firmware images (see + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`). + + ``bundle_id`` can appear in both ``running`` and ``stored`` versions, + but it must not be reported if any of the components covered by the + ``bundle_id`` was changed and no longer matches the version from + the bundle. board.id --------@@ -52,7 +136,7 @@ ASIC design identifier. asic.rev -------- -ASIC design revision. +ASIC design revision/stepping. board.manufacture -----------------@@ -91,10 +175,26 @@ Network Controller Sideband Interface. fw.psid ------- -Unique identifier of the firmware parameter set. +Unique identifier of the firmware parameter set. These are usually +parameters of a particular board, defined at manufacturing time. fw.roce ------- RoCE firmware version which is responsible for handling roce management. + +Future work +=========== + +The following extensions could be useful: + + - product serial number - NIC boards often get labeled with a board serial + number rather than ASIC serial number, it'd be useful to add board serial + numbers to the API if they can be retrieved from the device; + + - on-disk firmware file names - drivers list the file names of firmware they + may need to load onto devices via the ``MODULE_FIRMWARE()`` macro. These, + however, are per module, rather than per device. It'd be useful to list + the names of firmware files the driver will try to load for a given device, + in order of priority.Documentation/networking/devlink/devlink-params.rst +2
-0@@ -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 mayDocumentation/networking/devlink/index.rst +1
-0@@ -16,6 +16,7 @@ general. devlink-dpipe devlink-health devlink-info + devlink-flash devlink-params devlink-region devlink-resource
Randy Dunlap
reviewerHi-
Here are a few small changes for you to consider:
Quoted 28 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.
Signed-off-by Jakub Kicinski <[email protected]>--- .../networking/devlink/devlink-flash.rst | 88 ++++++++++++ .../networking/devlink/devlink-info.rst | 132 +++++++++++++++--- .../networking/devlink/devlink-params.rst | 2 + Documentation/networking/devlink/index.rst | 1 + 4 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 Documentation/networking/devlink/devlink-flash.rstDocumentation/networking/devlink/devlink-flash.rst new file +0
-0
Documentation/networking/devlink/devlink-flash.rst line 9
Quoted 9 lines
Documentation/networking/devlink/devlink-flash.rst new file +9
-0@@ -0,0 +1,88 @@ +.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +.. _devlink_flash: + +============= +Devlink Flash +============= + +The ``devlink-flash`` allows updating device firmware. It replaces the
The ``devlink-flash`` {option, mechanism, command, utility, something} allows
Quoted 5 lines
Documentation/networking/devlink/devlink-flash.rst new file +5
-0+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 +
Documentation/networking/devlink/devlink-flash.rst line 24
Quoted 10 lines
Documentation/networking/devlink/devlink-flash.rst new file +10
-0+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 driver loads the rest from disk during probing.
and {a, the} driver loads
Documentation/networking/devlink/devlink-flash.rst line 28
Quoted 4 lines
Documentation/networking/devlink/devlink-flash.rst new file +4
-0+``devlink-info`` allows users to query firmware information (loaded +components and versions). + +In other cases device can both store the image on the board, load from
cases {a, the} device
Documentation/networking/devlink/devlink-flash.rst line 29
Quoted 1 line
Documentation/networking/devlink/devlink-flash.rst new file +1
-0+disk, or automatically flash a new image from disk. ``fw_load_policy``
The ``fw_load_policy``
Quoted 6 lines
Documentation/networking/devlink/devlink-flash.rst new file +6
-0+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
Documentation/networking/devlink/devlink-flash.rst line 45
Quoted 10 lines
Documentation/networking/devlink/devlink-flash.rst new file +10
-0+=========================== + +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``). + +``driver`` and ``fixed`` group identify the specific device design,
The ``driver`` and ``fixed`` groups
Quoted 25 lines
Documentation/networking/devlink/devlink-flash.rst new file +25
-0+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
Documentation/networking/devlink/devlink-flash.rst line 80
Quoted 10 lines
Documentation/networking/devlink/devlink-flash.rst new file +10
-0+ $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/') + + # Reboot if necessary + if $want_fw_vers != devlink-dev-info['running']: + reboot()
or device reset? or is that expected/given already?
Quoted 42 lines
Documentation/networking/devlink/devlink-flash.rst new file +8
-0+ +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 +16
-5@@ -5,34 +5,118 @@ Devlink Info ============ The ``devlink-info`` mechanism enables device drivers to report device -information in a generic fashion. It is extensible, and enables exporting -even device or driver specific information. +(hardware and firmware) information in a standard, extensible fashion. -devlink supports representing the following types of versions +The original motivation for the ``devlink-info`` API was twofold: -.. list-table:: List of version types + - making it possible to automate device and firmware management in a fleet + of machines in a vendor-independent fashion (see also + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`); + - name the per component FW versions (as opposed to the crowded ethtool + version string). + +``devlink-info`` supports reporting multiple types of objects. Reporting driver +versions is generally discouraged - here, and via any other Linux API. + +.. list-table:: List of top level info objects :widths: 5 95 - * - Type + * - Name - Description + * - ``driver`` + - Name of the currently used device driver, also available through sysfs. +
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 38
Quoted 10 lines
Documentation/networking/devlink/devlink-info.rst +10
-0+ * - ``serial_number`` + - Serial number of the device. + + This is usually the serial number of the ASIC, also often available + in PCI config space of the device in the *Device Serial Number* + capability. + + The serial number should be unique per physical device. + Sometimes the serial number of the device is only 48 bits long (the + length of the Ethernet MAC address), and since PCI DSN is 64 bits long
long,
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 43
Quoted 5 lines
Documentation/networking/devlink/devlink-info.rst +5
-0+ devices pad or encode additional information into the serial number. + One example is adding port ID or PCI interface ID in the extra two bytes. + Drivers should make sure to strip or normalize any such padding + or interface ID, and report only the part of the serial number + which uniquely identify the hardware. In other words serial number
identifies
Quoted 5 lines
Documentation/networking/devlink/devlink-info.rst +5
-0+ reported for two ports of the same device or on two hosts of + a multi-host device should be identical. + + .. note:: ``devlink-info`` API should be extended with a new field + if devices want to report board/product serial number (often
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 57
Quoted 10 lines
Documentation/networking/devlink/devlink-info.rst +7
-1+ reported in PCI *Vital Product Data* capability). + * - ``fixed`` - - Represents fixed versions, which cannot change. For example, + - Group for hardware identifiers, and versions of components + which are not field-updatable. + + Versions in this section identify the device design. For example, component identifiers or the board version reported in the PCI VPD. + Data in ``devlink-info`` should be broken into smallest logical
into the smallest logical
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 59
Quoted 2 lines
Documentation/networking/devlink/devlink-info.rst +2
-0+ components, e.g. PCI VPD may concatenate various information + to form the Part Number string, in ``devlink-info`` all parts
while in ``devlink-info`` all parts
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 62
Quoted 3 lines
Documentation/networking/devlink/devlink-info.rst +3
-0+ should be reported as separate items. + + This groups must not contain any frequently changing identifiers,
This group
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 24
Quoted 8 lines
Documentation/networking/devlink/devlink-info.rst +4
-3+ such as serial numbers. See + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>` + to understand why. + * - ``running`` - - Represents the version of the currently running component. For - example the running version of firmware. These versions generally - only update after a reboot.
not reset?
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 69
Quoted 2 lines
Documentation/networking/devlink/devlink-info.rst +2
-0+ - Group for information about currently running software/firmware. + These versions often only update after a reboot, sometimes device reset.
oh. ok.
Quoted 4 lines
Documentation/networking/devlink/devlink-info.rst +1
-2+ * - ``stored`` - - Represents the version of a component as stored, such as after a - flash update. Stored values should update to reflect changes in the
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 80
Quoted 10 lines
Documentation/networking/devlink/devlink-info.rst +9
-1- flash even if a reboot has not yet occurred. + - Group for software/firmware versions in device flash. + + Stored values must update to reflect changes in the flash even + if reboot has not yet occurred. If device is not capable of updating + ``stored`` versions when new software is flashed, it must not report + them. + +Each version can be reported at most once in each version group. Firmware +components stored on the flash should feature both in ``running`` and
in both the ``running`` and
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 81
Quoted 1 line
Documentation/networking/devlink/devlink-info.rst +1
-0+``stored`` section, if device is capable of reporting ``stored`` versions
``stored`` sections, if the device
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 84
Quoted 3 lines
Documentation/networking/devlink/devlink-info.rst +3
-0+(see :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`). +In case software/firmware components are loaded from the disk (e.g. +``/lib/firmware``) only running version should be reported via the kernel API.
only the running version
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 90
Quoted 8 lines
Documentation/networking/devlink/devlink-info.rst +1
-2Generic Versions ================ It is expected that drivers use the following generic names for exporting -version information. Other information may be exposed using driver-specific -names, but these should be documented in the driver-specific file. +version information. If generic name for given component doesn't exist, yet,
If a generic name for a given component doesn't exist yet,
Documentation/networking/devlink/devlink-info.rst Devlink Info · line 92
Quoted 2 lines
Documentation/networking/devlink/devlink-info.rst +2
-0+driver authors should consult existing driver-specific versions and attempt +reuse. As last resort, if component is truly unique, using driver-specific
if a component
Quoted 50 lines
Documentation/networking/devlink/devlink-info.rst +30
-2+names is allowed, but these should be documented in the driver-specific file. + +All versions should try to use the following terminology: + +.. list-table:: List of common version suffixes + :widths: 10 90 + + * - Name + - Description + * - ``id``, ``revision`` + - Identifiers of designs and revision, mostly used for hardware versions. + + * - ``api`` + - Version of API between components. API items are usually of limited + value to the user, and can be inferred from other versions by the vendor, + so adding API versions is generally discouraged as noise. + + * - ``bundle_id`` + - Identifier of a distribution package which was flashed onto the device. + This is an attribute of a firmware package which covers multiple versions + for ease of managing firmware images (see + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`). + + ``bundle_id`` can appear in both ``running`` and ``stored`` versions, + but it must not be reported if any of the components covered by the + ``bundle_id`` was changed and no longer matches the version from + the bundle. board.id --------@@ -52,7 +136,7 @@ ASIC design identifier. asic.rev -------- -ASIC design revision. +ASIC design revision/stepping. board.manufacture -----------------@@ -91,10 +175,26 @@ Network Controller Sideband Interface. fw.psid ------- -Unique identifier of the firmware parameter set. +Unique identifier of the firmware parameter set. These are usually +parameters of a particular board, defined at manufacturing time. fw.roce -------
Documentation/networking/devlink/devlink-info.rst Network Controller Sideband Interface. · line 193
Quoted 10 lines
Documentation/networking/devlink/devlink-info.rst +8
-0RoCE firmware version which is responsible for handling roce management. + +Future work +=========== + +The following extensions could be useful: + + - product serial number - NIC boards often get labeled with a board serial + number rather than ASIC serial number, it'd be useful to add board serial
number;
Quoted 7 lines
Documentation/networking/devlink/devlink-info.rst +7
-0+ numbers to the API if they can be retrieved from the device; + + - on-disk firmware file names - drivers list the file names of firmware they + may need to load onto devices via the ``MODULE_FIRMWARE()`` macro. These, + however, are per module, rather than per device. It'd be useful to list + the names of firmware files the driver will try to load for a given device, + in order of priority.
Signature · 1 line
~Randy
Quoted 18 lines · Jacob Keller
Quoted 5 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.
Quoted 8 lines
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.>
Signed-off-by Jakub Kicinski <[email protected]>
Quoted 6 lines
This looks great! It's nice to see some of the expectations defined clearly.
Having a document for the
devlink-flash.rstis also a nice improvement.Thanks,
Jake
+1, Thank you.
Quoted 303 lines
Quoted 303 lines
--- .../networking/devlink/devlink-flash.rst | 88 ++++++++++++ .../networking/devlink/devlink-info.rst | 132 +++++++++++++++--- .../networking/devlink/devlink-params.rst | 2 + Documentation/networking/devlink/index.rst | 1 + 4 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 Documentation/networking/devlink/devlink-flash.rstDocumentation/networking/devlink/devlink-flash.rst new file +88
-0@@ -0,0 +1,88 @@ +.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +.. _devlink_flash: + +============= +Devlink Flash +============= + +The ``devlink-flash`` 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 driver loads the rest from disk during probing. +``devlink-info`` allows users to query firmware information (loaded +components and versions). + +In other cases device can both store the image on the board, load from +disk, or automatically flash a new image from disk. ``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``). + +``driver`` 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/') + + # Reboot if necessary + 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 +116
-16@@ -5,34 +5,118 @@ Devlink Info ============ The ``devlink-info`` mechanism enables device drivers to report device -information in a generic fashion. It is extensible, and enables exporting -even device or driver specific information. +(hardware and firmware) information in a standard, extensible fashion. -devlink supports representing the following types of versions +The original motivation for the ``devlink-info`` API was twofold: -.. list-table:: List of version types + - making it possible to automate device and firmware management in a fleet + of machines in a vendor-independent fashion (see also + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`); + - name the per component FW versions (as opposed to the crowded ethtool + version string). + +``devlink-info`` supports reporting multiple types of objects. Reporting driver +versions is generally discouraged - here, and via any other Linux API. + +.. list-table:: List of top level info objects :widths: 5 95 - * - Type + * - Name - Description + * - ``driver`` + - Name of the currently used device driver, also available through sysfs. + + * - ``serial_number`` + - Serial number of the device. + + This is usually the serial number of the ASIC, also often available + in PCI config space of the device in the *Device Serial Number* + capability. + + The serial number should be unique per physical device. + Sometimes the serial number of the device is only 48 bits long (the + length of the Ethernet MAC address), and since PCI DSN is 64 bits long + devices pad or encode additional information into the serial number. + One example is adding port ID or PCI interface ID in the extra two bytes. + Drivers should make sure to strip or normalize any such padding + or interface ID, and report only the part of the serial number + which uniquely identify the hardware. In other words serial number + reported for two ports of the same device or on two hosts of + a multi-host device should be identical. + + .. note:: ``devlink-info`` API should be extended with a new field + if devices want to report board/product serial number (often + reported in PCI *Vital Product Data* capability). + * - ``fixed`` - - Represents fixed versions, which cannot change. For example, + - Group for hardware identifiers, and versions of components + which are not field-updatable. + + Versions in this section identify the device design. For example, component identifiers or the board version reported in the PCI VPD. + Data in ``devlink-info`` should be broken into smallest logical + components, e.g. PCI VPD may concatenate various information + to form the Part Number string, in ``devlink-info`` all parts + should be reported as separate items. + + This groups must not contain any frequently changing identifiers, + such as serial numbers. See + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>` + to understand why. + * - ``running`` - - Represents the version of the currently running component. For - example the running version of firmware. These versions generally - only update after a reboot. + - Group for information about currently running software/firmware. + These versions often only update after a reboot, sometimes device reset. + * - ``stored`` - - Represents the version of a component as stored, such as after a - flash update. Stored values should update to reflect changes in the - flash even if a reboot has not yet occurred. + - Group for software/firmware versions in device flash. + + Stored values must update to reflect changes in the flash even + if reboot has not yet occurred. If device is not capable of updating + ``stored`` versions when new software is flashed, it must not report + them. + +Each version can be reported at most once in each version group. Firmware +components stored on the flash should feature both in ``running`` and +``stored`` section, if device is capable of reporting ``stored`` versions +(see :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`). +In case software/firmware components are loaded from the disk (e.g. +``/lib/firmware``) only running version should be reported via the kernel API. Generic Versions ================ It is expected that drivers use the following generic names for exporting -version information. Other information may be exposed using driver-specific -names, but these should be documented in the driver-specific file. +version information. If generic name for given component doesn't exist, yet, +driver authors should consult existing driver-specific versions and attempt +reuse. As last resort, if 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: + +.. list-table:: List of common version suffixes + :widths: 10 90 + + * - Name + - Description + * - ``id``, ``revision`` + - Identifiers of designs and revision, mostly used for hardware versions. + + * - ``api`` + - Version of API between components. API items are usually of limited + value to the user, and can be inferred from other versions by the vendor, + so adding API versions is generally discouraged as noise. + + * - ``bundle_id`` + - Identifier of a distribution package which was flashed onto the device. + This is an attribute of a firmware package which covers multiple versions + for ease of managing firmware images (see + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>`). + + ``bundle_id`` can appear in both ``running`` and ``stored`` versions, + but it must not be reported if any of the components covered by the + ``bundle_id`` was changed and no longer matches the version from + the bundle. board.id --------@@ -52,7 +136,7 @@ ASIC design identifier. asic.rev -------- -ASIC design revision. +ASIC design revision/stepping. board.manufacture -----------------@@ -91,10 +175,26 @@ Network Controller Sideband Interface. fw.psid ------- -Unique identifier of the firmware parameter set. +Unique identifier of the firmware parameter set. These are usually +parameters of a particular board, defined at manufacturing time. fw.roce ------- RoCE firmware version which is responsible for handling roce management. + +Future work +=========== + +The following extensions could be useful: + + - product serial number - NIC boards often get labeled with a board serial + number rather than ASIC serial number, it'd be useful to add board serial + numbers to the API if they can be retrieved from the device; + + - on-disk firmware file names - drivers list the file names of firmware they + may need to load onto devices via the ``MODULE_FIRMWARE()`` macro. These, + however, are per module, rather than per device. It'd be useful to list + the names of firmware files the driver will try to load for a given device, + in order of priority.Documentation/networking/devlink/devlink-params.rst +2
-0@@ -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 mayDocumentation/networking/devlink/index.rst +1
-0@@ -16,6 +16,7 @@ general. devlink-dpipe devlink-health devlink-info + devlink-flash devlink-params devlink-region devlink-resource
Jakub Kicinski
maintainerQuoted 2 lines · On Mon, 23 Mar 2020 18:38:57 -0700 Randy Dunlap wrote:
Hi-
Here are a few small changes for you to consider:
Thanks a lot for the corrections!
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines
Documentation/networking/devlink/devlink-flash.rst new file +3
-0@@ -0,0 +1,88 @@ +.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +.. _devlink_flash:
Quoted 8 lines
Documentation/networking/devlink/devlink-flash.rst line 9
Quoted 6 lines
Documentation/networking/devlink/devlink-flash.rst new file +6
-0+ +============= +Devlink Flash +============= + +The ``devlink-flash`` allows updating device firmware. It replaces theThe ``devlink-flash`` {option, mechanism, command, utility, something} allows
API
Quoted 10 lines
Quoted 10 lines
Documentation/networking/devlink/devlink-flash.rst new file +10
-0+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
Quoted 8 lines
Documentation/networking/devlink/devlink-flash.rst line 45
Quoted 6 lines
Documentation/networking/devlink/devlink-flash.rst new file +6
-0+automated firmware update facilities. + +``devlink-info`` exposes the ``driver`` name and three version groups +(``fixed``, ``running``, ``stored``). + +``driver`` and ``fixed`` group identify the specific device design,The ``driver`` and ``fixed`` groups
The ``driver`` attribute and ``fixed`` group
(Only ``fixed`` is a group, driver is a single attr.)
Quoted 29 lines
Quoted 29 lines
Documentation/networking/devlink/devlink-flash.rst new file +29
-0+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']:
Quoted 8 lines
Documentation/networking/devlink/devlink-flash.rst line 80
Quoted 6 lines
Documentation/networking/devlink/devlink-flash.rst new file +6
-0+ $file = some-db-backed.download($hw_id, 'disk') + write($file, '/lib/firmware/') + + # Reboot if necessary + if $want_fw_vers != devlink-dev-info['running']: + reboot()or device reset? or is that expected/given already?
We don't have an API to tell use which one is necessary, let me do:
# 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()
Quoted 9 lines
Documentation/networking/devlink/devlink-flash.rst
Quoted 8 lines
Documentation/networking/devlink/devlink-flash.rst new file +4
-3+ such as serial numbers. See + :ref:`Documentation/networking/devlink/devlink-flash.rst <devlink_flash>` + to understand why. + * - ``running`` - - Represents the version of the currently running component. For - example the running version of firmware. These versions generally - only update after a reboot.
Quoted 6 lines
not reset?
Documentation/networking/devlink/devlink-flash.rst
Quoted 2 lines
Documentation/networking/devlink/devlink-flash.rst new file +2
-0+ - Group for information about currently running software/firmware. + These versions often only update after a reboot, sometimes device reset.oh. ok.
Yup, some of the FW controls PCI interfaces etc. which is pretty hard to update without upsetting the host.
All other suggestions applied, thanks!