0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 ================
0004 Devlink Resource
0005 ================
0006
0007 ``devlink`` provides the ability for drivers to register resources, which
0008 can allow administrators to see the device restrictions for a given
0009 resource, as well as how much of the given resource is currently
0010 in use. Additionally, these resources can optionally have configurable size.
0011 This could enable the administrator to limit the number of resources that
0012 are used.
0013
0014 For example, the ``netdevsim`` driver enables ``/IPv4/fib`` and
0015 ``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries and
0016 rules for a given device.
0017
0018 Resource Ids
0019 ============
0020
0021 Each resource is represented by an id, and contains information about its
0022 current size and related sub resources. To access a sub resource, you
0023 specify the path of the resource. For example ``/IPv4/fib`` is the id for
0024 the ``fib`` sub-resource under the ``IPv4`` resource.
0025
0026 Generic Resources
0027 =================
0028
0029 Generic resources are used to describe resources that can be shared by multiple
0030 device drivers and their description must be added to the following table:
0031
0032 .. list-table:: List of Generic Resources
0033 :widths: 10 90
0034
0035 * - Name
0036 - Description
0037 * - ``physical_ports``
0038 - A limited capacity of physical ports that the switch ASIC can support
0039
0040 example usage
0041 -------------
0042
0043 The resources exposed by the driver can be observed, for example:
0044
0045 .. code:: shell
0046
0047 $devlink resource show pci/0000:03:00.0
0048 pci/0000:03:00.0:
0049 name kvd size 245760 unit entry
0050 resources:
0051 name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
0052 name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
0053 name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
0054
0055 Some resource's size can be changed. Examples:
0056
0057 .. code:: shell
0058
0059 $devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
0060 $devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
0061
0062 The changes do not apply immediately, this can be validated by the 'size_new'
0063 attribute, which represents the pending change in size. For example:
0064
0065 .. code:: shell
0066
0067 $devlink resource show pci/0000:03:00.0
0068 pci/0000:03:00.0:
0069 name kvd size 245760 unit entry size_valid false
0070 resources:
0071 name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
0072 name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
0073 name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
0074
0075 Note that changes in resource size may require a device reload to properly
0076 take effect.