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