devlink-resource.rst 2.3 KB

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