^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Devlink Resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ``devlink`` provides the ability for drivers to register resources, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) can allow administrators to see the device restrictions for a given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) resource, as well as how much of the given resource is currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) in use. Additionally, these resources can optionally have configurable size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) This could enable the administrator to limit the number of resources that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) For example, the ``netdevsim`` driver enables ``/IPv4/fib`` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) rules for a given device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Resource Ids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) Each resource is represented by an id, and contains information about its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) current size and related sub resources. To access a sub resource, you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) specify the path of the resource. For example ``/IPv4/fib`` is the id for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) the ``fib`` sub-resource under the ``IPv4`` resource.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) example usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) The resources exposed by the driver can be observed, for example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) .. code:: shell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) $devlink resource show pci/0000:03:00.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) pci/0000:03:00.0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) name kvd size 245760 unit entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) resources:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Some resource's size can be changed. Examples:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .. code:: shell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) $devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) $devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) The changes do not apply immediately, this can be validated by the 'size_new'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) attribute, which represents the pending change in size. For example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .. code:: shell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) $devlink resource show pci/0000:03:00.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) pci/0000:03:00.0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) name kvd size 245760 unit entry size_valid false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) resources:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) Note that changes in resource size may require a device reload to properly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) take effect.