요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. 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.
Overwrite Mask
==============
The ``devlink-flash`` command allows optionally specifying a mask indicating
how the device should handle subsections of flash components when updating.
This mask indicates the set of sections which are allowed to be overwritten.
.. list-table:: List of overwrite mask bits
:widths: 5 95
* - Name
- Description
* - ``DEVLINK_FLASH_OVERWRITE_SETTINGS``
- Indicates that the device should overwrite settings in the components
being updated with the settings found in the provided image.
* - ``DEVLINK_FLASH_OVERWRITE_IDENTIFIERS``
- Indicates that the device should overwrite identifiers in the
components being updated with the identifiers found in the provided
image. This includes MAC addresses, serial IDs, and similar device
identifiers.
Multiple overwrite bits may be combined and requested together. If no bits
are provided, it is expected that the device only update firmware binaries
in the components being updated. Settings and identifiers are expected to be
preserved across the update. A device may not support every combination and
the driver for such a device must reject any combination which cannot be
faithfully implemented.
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.)
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Devlink Flash 소개
1-18이 문서는 `GPL-2.0-only OR BSD-2-Clause` 이중 라이선스를 따릅니다.
Devlink Flash
`devlink-flash` API는 장치 firmware를 갱신합니다. 이전 `ethtool-flash` mechanism을 대체하며, flash update를 수행할 때 kernel의 networking lock을 잡을 필요가 없습니다.
$ devlink dev flash pci/0000:05:00.0 file flash-boot.bin
file 이름은 firmware loading path, 일반적으로 `/lib/firmware/`를 기준으로 한 상대 경로입니다. driver는 update 진행 상황을 userspace에 알리는 status update를 보낼 수 있습니다.
.. 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.
Flash overwrite mask
19-46Overwrite mask
`devlink-flash` command에는 update 중 flash component의 subsection을 장치가 어떻게 처리할지 나타내는 mask를 선택적으로 지정할 수 있습니다. 이 mask는 덮어써도 되는 section 집합을 뜻합니다.
firmware image의 설정과 식별자를 장치에 적용할지 선택합니다.
여러 overwrite bit를 결합해 함께 요청할 수 있습니다. bit를 지정하지 않으면 update 대상 component의 firmware binary만 갱신하고 설정과 식별자는 보존해야 합니다.
장치가 모든 조합을 지원할 필요는 없습니다. driver는 정확하게 구현할 수 없는 조합을 거부해야 합니다.
Overwrite Mask
==============
The ``devlink-flash`` command allows optionally specifying a mask indicating
how the device should handle subsections of flash components when updating.
This mask indicates the set of sections which are allowed to be overwritten.
.. list-table:: List of overwrite mask bits
:widths: 5 95
* - Name
- Description
* - ``DEVLINK_FLASH_OVERWRITE_SETTINGS``
- Indicates that the device should overwrite settings in the components
being updated with the settings found in the provided image.
* - ``DEVLINK_FLASH_OVERWRITE_IDENTIFIERS``
- Indicates that the device should overwrite identifiers in the
components being updated with the identifiers found in the provided
image. This includes MAC addresses, serial IDs, and similar device
identifiers.
Multiple overwrite bits may be combined and requested together. If no bits
are provided, it is expected that the device only update firmware binaries
in the components being updated. Settings and identifiers are expected to be
preserved across the update. A device may not support every combination and
the driver for such a device must reject any combination which cannot be
faithfully implemented.
Firmware loading
47-62Firmware loading
동작에 firmware가 필요한 장치는 보통 board의 flash 같은 non-volatile memory에 firmware를 저장합니다. 일부 장치는 기본 firmware만 board에 저장하고, 나머지는 driver probe 중 disk에서 불러옵니다. `devlink-info`를 사용하면 loading된 component와 version 같은 firmware 정보를 조회할 수 있습니다.
어떤 장치는 image를 board에 저장하거나 disk에서 loading할 수 있으며, disk의 새 image를 자동으로 flash할 수도 있습니다. `fw_load_policy` devlink parameter로 이 동작을 제어합니다. 자세한 내용은 `Documentation/networking/devlink/devlink-params.rst`를 참조하십시오.
disk의 firmware file은 일반적으로 `/lib/firmware/`에 저장합니다.
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 관리
63-121Firmware version 관리
driver는 `devlink-flash`와 `devlink-info`를 구현해야 합니다. 두 기능을 함께 사용하면 vendor에 종속되지 않는 자동 firmware update 기능을 만들 수 있습니다.
`devlink-info`는 `driver` 이름과 `fixed`, `running`, `stored`의 세 version group을 노출합니다.
hardware 설계와 현재·다음 firmware 상태를 구분합니다.
`driver` attribute와 `fixed` group은 특정 장치 설계를 식별하며, 예를 들어 적용 가능한 firmware update를 찾는 데 사용합니다. `serial_number`는 고정값이지만 단일 장치를 식별하므로 `fixed` version에 속하지 않습니다. `fixed`는 개별 장치가 아니라 설계를 식별해야 합니다.
`running`과 `stored` version은 각각 현재 실행 중인 firmware와 reboot 또는 device reset 뒤 활성화될 firmware를 식별합니다.
firmware update agent는 장치 vendor와 관계없이 다음 알고리즘을 따라 firmware 내용을 갱신할 수 있어야 합니다.
# 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()
이 pseudo-code에서 `devlink-dev-info`를 참조할 때마다 kernel에서 최신 정보를 다시 가져와야 합니다.
firmware file 식별을 편리하게 하려고 일부 vendor는 firmware version에 `bundle_id`를 추가합니다. 이 meta-version은 여러 component version을 포괄하므로 firmware file 이름 등에 사용할 수 있습니다. component version을 모두 이어 붙이면 이름이 지나치게 길어질 수 있습니다.
설계 식별자에 맞는 image를 선택하고 stored·running 상태를 차례로 맞춥니다.
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.)
요약·해설
devlink-flash.rst:1-121`devlink-flash`는 firmware binary를 갱신하면서 설정과 장치 식별자를 보존하거나 명시적으로 덮어쓸 수 있게 합니다. 자동 update 도구는 `fixed`로 설계를 식별하고 `stored`와 `running`을 비교해 flash, disk image, reset, reboot 순서를 결정합니다.
현재 상태를 목표 version과 비교해 필요한 단계만 수행합니다.