요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
================
Devlink Resource
================
``devlink`` provides the ability for drivers to register resources, which
can allow administrators to see the device restrictions for a given
resource, as well as how much of the given resource is currently
in use. Additionally, these resources can optionally have configurable size.
This could enable the administrator to limit the number of resources that
are used.
For example, the ``netdevsim`` driver enables ``/IPv4/fib`` and
``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries and
rules for a given device.
Resource Ids
============
Each resource is represented by an id, and contains information about its
current size and related sub resources. To access a sub resource, you
specify the path of the resource. For example ``/IPv4/fib`` is the id for
the ``fib`` sub-resource under the ``IPv4`` resource.
Generic Resources
=================
Generic resources are used to describe resources that can be shared by multiple
device drivers and their description must be added to the following table:
.. list-table:: List of Generic Resources
:widths: 10 90
* - Name
- Description
* - ``physical_ports``
- A limited capacity of physical ports that the switch ASIC can support
example usage
-------------
The resources exposed by the driver can be observed, for example:
.. code:: shell
$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 245760 unit entry
resources:
name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
Some resource's size can be changed. Examples:
.. code:: shell
$devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
$devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
The changes do not apply immediately, this can be validated by the 'size_new'
attribute, which represents the pending change in size. For example:
.. code:: shell
$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 245760 unit entry size_valid false
resources:
name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
Note that changes in resource size may require a device reload to properly
take effect.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Devlink Resource 소개
1-17이 문서는 `GPL-2.0` 라이선스를 따릅니다.
Devlink Resource
`devlink`를 사용하면 driver가 resource를 등록할 수 있습니다. 관리자는 특정 resource에 대한 장치의 제한과 현재 사용량을 확인할 수 있습니다. Resource의 크기는 선택적으로 설정 가능할 수 있으며, 이를 통해 관리자가 사용되는 resource 수를 제한할 수 있습니다.
예를 들어 `netdevsim` driver는 `/IPv4/fib`와 `/IPv4/fib-rules`를 resource로 노출하여 지정 장치의 IPv4 FIB entry 및 rule 수를 제한할 수 있게 합니다.
.. SPDX-License-Identifier: GPL-2.0
================
Devlink Resource
================
``devlink`` provides the ability for drivers to register resources, which
can allow administrators to see the device restrictions for a given
resource, as well as how much of the given resource is currently
in use. Additionally, these resources can optionally have configurable size.
This could enable the administrator to limit the number of resources that
are used.
For example, the ``netdevsim`` driver enables ``/IPv4/fib`` and
``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries and
rules for a given device.
Resource ID
18-25Resource ID
각 resource는 ID로 표현되며 현재 크기와 관련 sub-resource 정보를 포함합니다. Sub-resource에 접근하려면 resource 경로를 지정합니다. 예를 들어 `/IPv4/fib`는 `IPv4` resource 아래 `fib` sub-resource의 ID입니다.
슬래시로 구분된 경로가 상위 resource와 sub-resource를 식별합니다.
Resource Ids
============
Each resource is represented by an id, and contains information about its
current size and related sub resources. To access a sub resource, you
specify the path of the resource. For example ``/IPv4/fib`` is the id for
the ``fib`` sub-resource under the ``IPv4`` resource.
Generic resource
26-39Generic resource
Generic resource는 여러 device driver가 공유할 수 있는 resource를 설명합니다. Generic resource의 설명은 다음 표에 추가해야 합니다.
여러 driver가 공통 이름과 의미로 노출하는 resource입니다.
Generic Resources
=================
Generic resources are used to describe resources that can be shared by multiple
device drivers and their description must be added to the following table:
.. list-table:: List of Generic Resources
:widths: 10 90
* - Name
- Description
* - ``physical_ports``
- A limited capacity of physical ports that the switch ASIC can support
Resource 조회와 크기 설정
40-61사용 예
Driver가 노출한 resource는 다음과 같이 조회할 수 있습니다.
$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 245760 unit entry
resources:
name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
일부 resource의 크기는 변경할 수 있습니다. 예시는 다음과 같습니다.
$devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
$devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
example usage
-------------
The resources exposed by the driver can be observed, for example:
.. code:: shell
$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 245760 unit entry
resources:
name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
Some resource's size can be changed. Examples:
.. code:: shell
$devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
$devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
대기 중인 크기 변경
62-76변경 사항은 즉시 적용되지 않습니다. 대기 중인 크기 변경을 나타내는 `size_new` attribute로 이를 확인할 수 있습니다.
$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 245760 unit entry size_valid false
resources:
name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
Resource 크기 변경을 제대로 적용하려면 장치를 reload해야 할 수 있습니다.
The changes do not apply immediately, this can be validated by the 'size_new'
attribute, which represents the pending change in size. For example:
.. code:: shell
$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 245760 unit entry size_valid false
resources:
name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
Note that changes in resource size may require a device reload to properly
take effect.
요약·해설
devlink-resource.rst:1-76Devlink resource는 switch ASIC 등의 제한된 내부 자원을 계층적 경로로 공개합니다. 관리자는 현재 크기와 점유량, 최소·최대·단위를 확인한 뒤 지원되는 resource의 새 크기를 예약할 수 있습니다. `size_new`는 아직 적용되지 않은 값이며 실제 반영에는 reload가 필요할 수 있습니다.
변경 전 제약을 확인하고 대기 값을 검증한 뒤 필요하면 reload합니다.