| 1 | |
| 2 |
|
| 3 | ================
|
| 4 | Devlink Resource
|
| 5 | ================
|
| 6 |
|
| 7 | ``devlink`` provides the ability for drivers to register resources, which
|
| 8 | can allow administrators to see the device restrictions for a given
|
| 9 | resource, as well as how much of the given resource is currently
|
| 10 | in use. Additionally, these resources can optionally have configurable size.
|
| 11 | This could enable the administrator to limit the number of resources that
|
| 12 | are used.
|
| 13 |
|
| 14 | For example, the ``netdevsim`` driver enables ``/IPv4/fib`` and
|
| 15 | ``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries and
|
| 16 | rules for a given device.
|
| 17 |
|
| 18 | Resource Ids
|
| 19 | ============
|
| 20 |
|
| 21 | Each resource is represented by an id, and contains information about its
|
| 22 | current size and related sub resources. To access a sub resource, you
|
| 23 | specify the path of the resource. For example ``/IPv4/fib`` is the id for
|
| 24 | the ``fib`` sub-resource under the ``IPv4`` resource.
|
| 25 |
|
| 26 | Generic Resources
|
| 27 | =================
|
| 28 |
|
| 29 | Generic resources are used to describe resources that can be shared by multiple
|
| 30 | device drivers and their description must be added to the following table:
|
| 31 |
|
| 32 | .. list-table:: List of Generic Resources
|
| 33 | :widths: 10 90
|
| 34 |
|
| 35 | * - Name
|
| 36 | - Description
|
| 37 | * - ``physical_ports``
|
| 38 | - A limited capacity of physical ports that the switch ASIC can support
|
| 39 |
|
| 40 | example usage
|
| 41 | -------------
|
| 42 |
|
| 43 | The resources exposed by the driver can be observed, for example:
|
| 44 |
|
| 45 | .. code:: shell
|
| 46 |
|
| 47 | $devlink resource show pci/0000:03:00.0
|
| 48 | pci/0000:03:00.0:
|
| 49 | name kvd size 245760 unit entry
|
| 50 | resources:
|
| 51 | name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
|
| 52 | name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
|
| 53 | name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
|
| 54 |
|
| 55 | Some resource's size can be changed. Examples:
|
| 56 |
|
| 57 | .. code:: shell
|
| 58 |
|
| 59 | $devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
|
| 60 | $devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368
|
| 61 |
|
| 62 | The changes do not apply immediately, this can be validated by the 'size_new'
|
| 63 | attribute, which represents the pending change in size. For example:
|
| 64 |
|
| 65 | .. code:: shell
|
| 66 |
|
| 67 | $devlink resource show pci/0000:03:00.0
|
| 68 | pci/0000:03:00.0:
|
| 69 | name kvd size 245760 unit entry size_valid false
|
| 70 | resources:
|
| 71 | name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
|
| 72 | name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
|
| 73 | name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128
|
| 74 |
|
| 75 | Note that changes in resource size may require a device reload to properly
|
| 76 | take effect.
|
| 77 |
|
| 78 | Port-level Resources and Full Dump
|
| 79 | ==================================
|
| 80 |
|
| 81 | In addition to device-level resources, ``devlink`` also supports port-level
|
| 82 | resources. These resources are associated with a specific devlink port rather
|
| 83 | than the device as a whole.
|
| 84 |
|
| 85 | To list resources for all devlink devices and ports:
|
| 86 |
|
| 87 | .. code:: shell
|
| 88 |
|
| 89 | $ devlink resource show
|
| 90 | pci/0000:03:00.0:
|
| 91 | name max_local_SFs size 128 unit entry dpipe_tables none
|
| 92 | name max_external_SFs size 128 unit entry dpipe_tables none
|
| 93 | pci/0000:03:00.0/196608:
|
| 94 | name max_SFs size 128 unit entry dpipe_tables none
|
| 95 | pci/0000:03:00.0/196609:
|
| 96 | name max_SFs size 128 unit entry dpipe_tables none
|
| 97 | pci/0000:03:00.1:
|
| 98 | name max_local_SFs size 128 unit entry dpipe_tables none
|
| 99 | name max_external_SFs size 128 unit entry dpipe_tables none
|
| 100 | pci/0000:03:00.1/196708:
|
| 101 | name max_SFs size 128 unit entry dpipe_tables none
|
| 102 | pci/0000:03:00.1/196709:
|
| 103 | name max_SFs size 128 unit entry dpipe_tables none
|
| 104 |
|
| 105 | To show resources for a specific port:
|
| 106 |
|
| 107 | .. code:: shell
|
| 108 |
|
| 109 | $ devlink resource show pci/0000:03:00.0/196608
|
| 110 | pci/0000:03:00.0/196608:
|
| 111 | name max_SFs size 128 unit entry dpipe_tables none
|
| 112 |
|
| 113 | Resource Scope Filtering
|
| 114 | ========================
|
| 115 |
|
| 116 | When dumping resources for all devices, ``devlink resource show`` accepts
|
| 117 | an optional ``scope`` parameter to restrict the response to device-level
|
| 118 | resources, port-level resources, or both (the default).
|
| 119 |
|
| 120 | To dump only device-level resources across all devices:
|
| 121 |
|
| 122 | .. code:: shell
|
| 123 |
|
| 124 | $ devlink resource show scope dev
|
| 125 | pci/0000:03:00.0:
|
| 126 | name max_local_SFs size 128 unit entry dpipe_tables none
|
| 127 | name max_external_SFs size 128 unit entry dpipe_tables none
|
| 128 | pci/0000:03:00.1:
|
| 129 | name max_local_SFs size 128 unit entry dpipe_tables none
|
| 130 | name max_external_SFs size 128 unit entry dpipe_tables none
|
| 131 |
|
| 132 | To dump only port-level resources across all devices:
|
| 133 |
|
| 134 | .. code:: shell
|
| 135 |
|
| 136 | $ devlink resource show scope port
|
| 137 | pci/0000:03:00.0/196608:
|
| 138 | name max_SFs size 128 unit entry dpipe_tables none
|
| 139 | pci/0000:03:00.0/196609:
|
| 140 | name max_SFs size 128 unit entry dpipe_tables none
|
| 141 | pci/0000:03:00.1/196708:
|
| 142 | name max_SFs size 128 unit entry dpipe_tables none
|
| 143 | pci/0000:03:00.1/196709:
|
| 144 | name max_SFs size 128 unit entry dpipe_tables none
|
| 145 |
|
| 146 | Note that port-level resources are read-only.
|