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