162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci================
462306a36Sopenharmony_ciDevlink Resource
562306a36Sopenharmony_ci================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci``devlink`` provides the ability for drivers to register resources, which
862306a36Sopenharmony_cican allow administrators to see the device restrictions for a given
962306a36Sopenharmony_ciresource, as well as how much of the given resource is currently
1062306a36Sopenharmony_ciin use. Additionally, these resources can optionally have configurable size.
1162306a36Sopenharmony_ciThis could enable the administrator to limit the number of resources that
1262306a36Sopenharmony_ciare used.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciFor example, the ``netdevsim`` driver enables ``/IPv4/fib`` and
1562306a36Sopenharmony_ci``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries and
1662306a36Sopenharmony_cirules for a given device.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciResource Ids
1962306a36Sopenharmony_ci============
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ciEach resource is represented by an id, and contains information about its
2262306a36Sopenharmony_cicurrent size and related sub resources. To access a sub resource, you
2362306a36Sopenharmony_cispecify the path of the resource. For example ``/IPv4/fib`` is the id for
2462306a36Sopenharmony_cithe ``fib`` sub-resource under the ``IPv4`` resource.
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciGeneric Resources
2762306a36Sopenharmony_ci=================
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ciGeneric resources are used to describe resources that can be shared by multiple
3062306a36Sopenharmony_cidevice drivers and their description must be added to the following table:
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci.. list-table:: List of Generic Resources
3362306a36Sopenharmony_ci   :widths: 10 90
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci   * - Name
3662306a36Sopenharmony_ci     - Description
3762306a36Sopenharmony_ci   * - ``physical_ports``
3862306a36Sopenharmony_ci     - A limited capacity of physical ports that the switch ASIC can support
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciexample usage
4162306a36Sopenharmony_ci-------------
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciThe resources exposed by the driver can be observed, for example:
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci.. code:: shell
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci    $devlink resource show pci/0000:03:00.0
4862306a36Sopenharmony_ci    pci/0000:03:00.0:
4962306a36Sopenharmony_ci      name kvd size 245760 unit entry
5062306a36Sopenharmony_ci        resources:
5162306a36Sopenharmony_ci          name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
5262306a36Sopenharmony_ci          name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
5362306a36Sopenharmony_ci          name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciSome resource's size can be changed. Examples:
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci.. code:: shell
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci    $devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
6062306a36Sopenharmony_ci    $devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciThe changes do not apply immediately, this can be validated by the 'size_new'
6362306a36Sopenharmony_ciattribute, which represents the pending change in size. For example:
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci.. code:: shell
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci    $devlink resource show pci/0000:03:00.0
6862306a36Sopenharmony_ci    pci/0000:03:00.0:
6962306a36Sopenharmony_ci      name kvd size 245760 unit entry size_valid false
7062306a36Sopenharmony_ci      resources:
7162306a36Sopenharmony_ci        name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
7262306a36Sopenharmony_ci        name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
7362306a36Sopenharmony_ci        name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciNote that changes in resource size may require a device reload to properly
7662306a36Sopenharmony_citake effect.
77