146 lines · 5.0 KB · Text
RawDownload
.. SPDX-License-Identifier: GPL-2.0 ================Devlink Resource================ ``devlink`` provides the ability for drivers to register resources, whichcan allow administrators to see the device restrictions for a givenresource, as well as how much of the given resource is currentlyin use. Additionally, these resources can optionally have configurable size.This could enable the administrator to limit the number of resources thatare used. For example, the ``netdevsim`` driver enables ``/IPv4/fib`` and``/IPv4/fib-rules`` as resources to limit the number of IPv4 FIB entries andrules for a given device. Resource Ids============ Each resource is represented by an id, and contains information about itscurrent size and related sub resources. To access a sub resource, youspecify the path of the resource. For example ``/IPv4/fib`` is the id forthe ``fib`` sub-resource under the ``IPv4`` resource. Generic Resources================= Generic resources are used to describe resources that can be shared by multipledevice drivers and their description must be added to the following table: .. list-table:: List of Generic Resources   :widths: 10 90    * - Name     - Description   * - ``physical_ports``     - A limited capacity of physical ports that the switch ASIC can support example usage------------- The resources exposed by the driver can be observed, for example: .. code:: shell     $devlink resource show pci/0000:03:00.0    pci/0000:03:00.0:      name kvd size 245760 unit entry        resources:          name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128          name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128          name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128 Some resource's size can be changed. Examples: .. code:: shell     $devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088    $devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368 The changes do not apply immediately, this can be validated by the 'size_new'attribute, which represents the pending change in size. For example: .. code:: shell     $devlink resource show pci/0000:03:00.0    pci/0000:03:00.0:      name kvd size 245760 unit entry size_valid false      resources:        name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128        name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128        name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128 Note that changes in resource size may require a device reload to properlytake effect. Port-level Resources and Full Dump================================== In addition to device-level resources, ``devlink`` also supports port-levelresources. These resources are associated with a specific devlink port ratherthan the device as a whole. To list resources for all devlink devices and ports: .. code:: shell     $ devlink resource show    pci/0000:03:00.0:      name max_local_SFs size 128 unit entry dpipe_tables none      name max_external_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.0/196608:      name max_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.0/196609:      name max_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.1:      name max_local_SFs size 128 unit entry dpipe_tables none      name max_external_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.1/196708:      name max_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.1/196709:      name max_SFs size 128 unit entry dpipe_tables none To show resources for a specific port: .. code:: shell     $ devlink resource show pci/0000:03:00.0/196608    pci/0000:03:00.0/196608:      name max_SFs size 128 unit entry dpipe_tables none Resource Scope Filtering======================== When dumping resources for all devices, ``devlink resource show`` acceptsan optional ``scope`` parameter to restrict the response to device-levelresources, port-level resources, or both (the default). To dump only device-level resources across all devices: .. code:: shell     $ devlink resource show scope dev    pci/0000:03:00.0:      name max_local_SFs size 128 unit entry dpipe_tables none      name max_external_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.1:      name max_local_SFs size 128 unit entry dpipe_tables none      name max_external_SFs size 128 unit entry dpipe_tables none To dump only port-level resources across all devices: .. code:: shell     $ devlink resource show scope port    pci/0000:03:00.0/196608:      name max_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.0/196609:      name max_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.1/196708:      name max_SFs size 128 unit entry dpipe_tables none    pci/0000:03:00.1/196709:      name max_SFs size 128 unit entry dpipe_tables none Note that port-level resources are read-only.