요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
Linux Devlink Documentation
===========================
devlink is an API to expose device information and resources not directly
related to any device class, such as chip-wide/switch-ASIC-wide configuration.
Locking
-------
Driver facing APIs are currently transitioning to allow more explicit
locking. Drivers can use the existing ``devlink_*`` set of APIs, or
new APIs prefixed by ``devl_*``. The older APIs handle all the locking
in devlink core, but don't allow registration of most sub-objects once
the main devlink object is itself registered. The newer ``devl_*`` APIs assume
the devlink instance lock is already held. Drivers can take the instance
lock by calling ``devl_lock()``. It is also held all callbacks of devlink
netlink commands.
Drivers are encouraged to use the devlink instance lock for their own needs.
Drivers need to be cautious when taking devlink instance lock and
taking RTNL lock at the same time. Devlink instance lock needs to be taken
first, only after that RTNL lock could be taken.
Nested instances
----------------
Some objects, like linecards or port functions, could have another
devlink instances created underneath. In that case, drivers should make
sure to respect following rules:
- Lock ordering should be maintained. If driver needs to take instance
lock of both nested and parent instances at the same time, devlink
instance lock of the parent instance should be taken first, only then
instance lock of the nested instance could be taken.
- Driver should use object-specific helpers to setup the
nested relationship:
- ``devl_nested_devlink_set()`` - called to setup devlink -> nested
devlink relationship (could be user for multiple nested instances.
- ``devl_port_fn_devlink_set()`` - called to setup port function ->
nested devlink relationship.
- ``devlink_linecard_nested_dl_set()`` - called to setup linecard ->
nested devlink relationship.
The nested devlink info is exposed to the userspace over object-specific
attributes of devlink netlink.
Interface documentation
-----------------------
The following pages describe various interfaces available through devlink in
general.
.. toctree::
:maxdepth: 1
devlink-dpipe
devlink-eswitch-attr
devlink-flash
devlink-health
devlink-info
devlink-linecard
devlink-params
devlink-port
devlink-region
devlink-reload
devlink-resource
devlink-selftests
devlink-trap
Driver-specific documentation
-----------------------------
Each driver that implements ``devlink`` is expected to document what
parameters, info versions, and other features it supports.
.. toctree::
:maxdepth: 1
am65-nuss-cpsw-switch
bnxt
etas_es58x
hns3
i40e
ice
ionic
iosm
ixgbe
kvaser_pciefd
kvaser_usb
mlx4
mlx5
mlxsw
mv88e6xxx
netdevsim
nfp
octeontx2
prestera
qed
sfc
ti-cpsw-switch
zl3073x
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Linux Devlink 문서
1-6Linux Devlink 문서
Devlink는 chip 전체 또는 switch ASIC 전체 configuration처럼 특정 device class와 직접 관련되지 않은 장치 정보와 resource를 노출하는 API입니다.
Linux Devlink Documentation
===========================
devlink is an API to expose device information and resources not directly
related to any device class, such as chip-wide/switch-ASIC-wide configuration.
Locking
7-24Locking
Driver-facing API는 더 명시적인 locking을 허용하는 방향으로 전환 중입니다. Driver는 기존 `devlink_*` API 집합이나 `devl_*` prefix가 붙은 새 API를 사용할 수 있습니다.
기존 API는 devlink core 안에서 모든 locking을 처리하지만 main devlink object를 등록한 뒤에는 대부분의 sub-object를 등록할 수 없습니다. 새 `devl_*` API는 devlink instance lock을 이미 보유하고 있다고 가정합니다. Driver는 `devl_lock()`을 호출해 instance lock을 획득할 수 있으며, 이 lock은 devlink netlink command의 모든 callback에서도 유지됩니다.
Driver는 자체 필요에도 devlink instance lock을 사용하도록 권장합니다.
Devlink instance lock과 RTNL lock을 동시에 획득할 때는 주의해야 합니다. 반드시 devlink instance lock을 먼저 획득한 뒤 RTNL lock을 획득해야 합니다.
동시 획득 시 허용되는 순서를 고정해 lock inversion을 피합니다.
Locking
-------
Driver facing APIs are currently transitioning to allow more explicit
locking. Drivers can use the existing ``devlink_*`` set of APIs, or
new APIs prefixed by ``devl_*``. The older APIs handle all the locking
in devlink core, but don't allow registration of most sub-objects once
the main devlink object is itself registered. The newer ``devl_*`` APIs assume
the devlink instance lock is already held. Drivers can take the instance
lock by calling ``devl_lock()``. It is also held all callbacks of devlink
netlink commands.
Drivers are encouraged to use the devlink instance lock for their own needs.
Drivers need to be cautious when taking devlink instance lock and
taking RTNL lock at the same time. Devlink instance lock needs to be taken
first, only after that RTNL lock could be taken.
Nested instance
25-48Nested instance
Linecard나 port function 같은 일부 object 아래에는 또 다른 devlink instance를 만들 수 있습니다. 이때 driver는 다음 규칙을 지켜야 합니다.
Nested instance와 parent instance의 lock을 동시에 획득해야 한다면 lock ordering을 유지해야 합니다. Parent instance의 devlink instance lock을 먼저 획득하고 그다음 nested instance lock을 획득합니다.
Object 종류별 helper로 parent와 nested devlink의 관계를 등록합니다.
Nested devlink 정보는 devlink netlink의 object별 attribute를 통해 user space에 노출됩니다.
Nested instances
----------------
Some objects, like linecards or port functions, could have another
devlink instances created underneath. In that case, drivers should make
sure to respect following rules:
- Lock ordering should be maintained. If driver needs to take instance
lock of both nested and parent instances at the same time, devlink
instance lock of the parent instance should be taken first, only then
instance lock of the nested instance could be taken.
- Driver should use object-specific helpers to setup the
nested relationship:
- ``devl_nested_devlink_set()`` - called to setup devlink -> nested
devlink relationship (could be user for multiple nested instances.
- ``devl_port_fn_devlink_set()`` - called to setup port function ->
nested devlink relationship.
- ``devlink_linecard_nested_dl_set()`` - called to setup linecard ->
nested devlink relationship.
The nested devlink info is exposed to the userspace over object-specific
attributes of devlink netlink.
Interface 문서
49-71Interface 문서
다음 문서는 devlink가 일반적으로 제공하는 여러 interface를 설명합니다.
devlink-dpipe
devlink-eswitch-attr
devlink-flash
devlink-health
devlink-info
devlink-linecard
devlink-params
devlink-port
devlink-region
devlink-reload
devlink-resource
devlink-selftests
devlink-trap
Interface documentation
-----------------------
The following pages describe various interfaces available through devlink in
general.
.. toctree::
:maxdepth: 1
devlink-dpipe
devlink-eswitch-attr
devlink-flash
devlink-health
devlink-info
devlink-linecard
devlink-params
devlink-port
devlink-region
devlink-reload
devlink-resource
devlink-selftests
devlink-trap
Driver별 문서
72-103Driver별 문서
`devlink`를 구현하는 각 driver는 자신이 지원하는 parameter, info version과 기타 기능을 문서화해야 합니다.
am65-nuss-cpsw-switch
bnxt
etas_es58x
hns3
i40e
ice
ionic
iosm
ixgbe
kvaser_pciefd
kvaser_usb
mlx4
mlx5
mlxsw
mv88e6xxx
netdevsim
nfp
octeontx2
prestera
qed
sfc
ti-cpsw-switch
zl3073x
Driver-specific documentation
-----------------------------
Each driver that implements ``devlink`` is expected to document what
parameters, info versions, and other features it supports.
.. toctree::
:maxdepth: 1
am65-nuss-cpsw-switch
bnxt
etas_es58x
hns3
i40e
ice
ionic
iosm
ixgbe
kvaser_pciefd
kvaser_usb
mlx4
mlx5
mlxsw
mv88e6xxx
netdevsim
nfp
octeontx2
prestera
qed
sfc
ti-cpsw-switch
zl3073x
요약·해설
index.rst:1-103Devlink는 특정 device class에 묶이지 않는 장치 전체 정보를 제공하는 관리 API입니다. Driver 개발 시 기존 `devlink_*`와 명시적 locking을 전제로 한 `devl_*` API의 차이를 이해하고, devlink instance lock을 RTNL보다 먼저 획득해야 합니다. Nested instance에서는 parent lock이 child lock보다 먼저입니다.
일반 lock과 nested instance lock에서 지켜야 할 선후 관계입니다.