devlink-resource.rst 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. Generic Resources
  21. =================
  22. Generic resources are used to describe resources that can be shared by multiple
  23. device drivers and their description must be added to the following table:
  24. .. list-table:: List of Generic Resources
  25. :widths: 10 90
  26. * - Name
  27. - Description
  28. * - ``physical_ports``
  29. - A limited capacity of physical ports that the switch ASIC can support
  30. example usage
  31. -------------
  32. The resources exposed by the driver can be observed, for example:
  33. .. code:: shell
  34. $devlink resource show pci/0000:03:00.0
  35. pci/0000:03:00.0:
  36. name kvd size 245760 unit entry
  37. resources:
  38. name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
  39. name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
  40. name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
  41. Some resource's size can be changed. Examples:
  42. .. code:: shell
  43. $devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
  44. $devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
  45. The changes do not apply immediately, this can be validated by the 'size_new'
  46. attribute, which represents the pending change in size. For example:
  47. .. code:: shell
  48. $devlink resource show pci/0000:03:00.0
  49. pci/0000:03:00.0:
  50. name kvd size 245760 unit entry size_valid false
  51. resources:
  52. name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
  53. name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
  54. name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
  55. Note that changes in resource size may require a device reload to properly
  56. take effect.