162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci.. _devlink_port: 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci============ 662306a36Sopenharmony_ciDevlink Port 762306a36Sopenharmony_ci============ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci``devlink-port`` is a port that exists on the device. It has a logically 1062306a36Sopenharmony_ciseparate ingress/egress point of the device. A devlink port can be any one 1162306a36Sopenharmony_ciof many flavours. A devlink port flavour along with port attributes 1262306a36Sopenharmony_cidescribe what a port represents. 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciA device driver that intends to publish a devlink port sets the 1562306a36Sopenharmony_cidevlink port attributes and registers the devlink port. 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciDevlink port flavours are described below. 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci.. list-table:: List of devlink port flavours 2062306a36Sopenharmony_ci :widths: 33 90 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci * - Flavour 2362306a36Sopenharmony_ci - Description 2462306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_PHYSICAL`` 2562306a36Sopenharmony_ci - Any kind of physical port. This can be an eswitch physical port or any 2662306a36Sopenharmony_ci other physical port on the device. 2762306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_DSA`` 2862306a36Sopenharmony_ci - This indicates a DSA interconnect port. 2962306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_CPU`` 3062306a36Sopenharmony_ci - This indicates a CPU port applicable only to DSA. 3162306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_PCI_PF`` 3262306a36Sopenharmony_ci - This indicates an eswitch port representing a port of PCI 3362306a36Sopenharmony_ci physical function (PF). 3462306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_PCI_VF`` 3562306a36Sopenharmony_ci - This indicates an eswitch port representing a port of PCI 3662306a36Sopenharmony_ci virtual function (VF). 3762306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_PCI_SF`` 3862306a36Sopenharmony_ci - This indicates an eswitch port representing a port of PCI 3962306a36Sopenharmony_ci subfunction (SF). 4062306a36Sopenharmony_ci * - ``DEVLINK_PORT_FLAVOUR_VIRTUAL`` 4162306a36Sopenharmony_ci - This indicates a virtual port for the PCI virtual function. 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciDevlink port can have a different type based on the link layer described below. 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci.. list-table:: List of devlink port types 4662306a36Sopenharmony_ci :widths: 23 90 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci * - Type 4962306a36Sopenharmony_ci - Description 5062306a36Sopenharmony_ci * - ``DEVLINK_PORT_TYPE_ETH`` 5162306a36Sopenharmony_ci - Driver should set this port type when a link layer of the port is 5262306a36Sopenharmony_ci Ethernet. 5362306a36Sopenharmony_ci * - ``DEVLINK_PORT_TYPE_IB`` 5462306a36Sopenharmony_ci - Driver should set this port type when a link layer of the port is 5562306a36Sopenharmony_ci InfiniBand. 5662306a36Sopenharmony_ci * - ``DEVLINK_PORT_TYPE_AUTO`` 5762306a36Sopenharmony_ci - This type is indicated by the user when driver should detect the port 5862306a36Sopenharmony_ci type automatically. 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ciPCI controllers 6162306a36Sopenharmony_ci--------------- 6262306a36Sopenharmony_ciIn most cases a PCI device has only one controller. A controller consists of 6362306a36Sopenharmony_cipotentially multiple physical, virtual functions and subfunctions. A function 6462306a36Sopenharmony_ciconsists of one or more ports. This port is represented by the devlink eswitch 6562306a36Sopenharmony_ciport. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciA PCI device connected to multiple CPUs or multiple PCI root complexes or a 6862306a36Sopenharmony_ciSmartNIC, however, may have multiple controllers. For a device with multiple 6962306a36Sopenharmony_cicontrollers, each controller is distinguished by a unique controller number. 7062306a36Sopenharmony_ciAn eswitch is on the PCI device which supports ports of multiple controllers. 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciAn example view of a system with two controllers:: 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci --------------------------------------------------------- 7562306a36Sopenharmony_ci | | 7662306a36Sopenharmony_ci | --------- --------- ------- ------- | 7762306a36Sopenharmony_ci ----------- | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | 7862306a36Sopenharmony_ci | server | | ------- ----/---- ---/----- ------- ---/--- ---/--- | 7962306a36Sopenharmony_ci | pci rc |=== | pf0 |______/________/ | pf1 |___/_______/ | 8062306a36Sopenharmony_ci | connect | | ------- ------- | 8162306a36Sopenharmony_ci ----------- | | controller_num=1 (no eswitch) | 8262306a36Sopenharmony_ci ------|-------------------------------------------------- 8362306a36Sopenharmony_ci (internal wire) 8462306a36Sopenharmony_ci | 8562306a36Sopenharmony_ci --------------------------------------------------------- 8662306a36Sopenharmony_ci | devlink eswitch ports and reps | 8762306a36Sopenharmony_ci | ----------------------------------------------------- | 8862306a36Sopenharmony_ci | |ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 | ctrl-0 |ctrl-0 | | 8962306a36Sopenharmony_ci | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | 9062306a36Sopenharmony_ci | ----------------------------------------------------- | 9162306a36Sopenharmony_ci | |ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 | ctrl-1 |ctrl-1 | | 9262306a36Sopenharmony_ci | |pf0 | pf0vfN | pf0sfN | pf1 | pf1vfN |pf1sfN | | 9362306a36Sopenharmony_ci | ----------------------------------------------------- | 9462306a36Sopenharmony_ci | | 9562306a36Sopenharmony_ci | | 9662306a36Sopenharmony_ci ----------- | --------- --------- ------- ------- | 9762306a36Sopenharmony_ci | smartNIC| | | vf(s) | | sf(s) | |vf(s)| |sf(s)| | 9862306a36Sopenharmony_ci | pci rc |==| ------- ----/---- ---/----- ------- ---/--- ---/--- | 9962306a36Sopenharmony_ci | connect | | | pf0 |______/________/ | pf1 |___/_______/ | 10062306a36Sopenharmony_ci ----------- | ------- ------- | 10162306a36Sopenharmony_ci | | 10262306a36Sopenharmony_ci | local controller_num=0 (eswitch) | 10362306a36Sopenharmony_ci --------------------------------------------------------- 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ciIn the above example, the external controller (identified by controller number = 1) 10662306a36Sopenharmony_cidoesn't have the eswitch. Local controller (identified by controller number = 0) 10762306a36Sopenharmony_cihas the eswitch. The Devlink instance on the local controller has eswitch 10862306a36Sopenharmony_cidevlink ports for both the controllers. 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ciFunction configuration 11162306a36Sopenharmony_ci====================== 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ciUsers can configure one or more function attributes before enumerating the PCI 11462306a36Sopenharmony_cifunction. Usually it means, user should configure function attribute 11562306a36Sopenharmony_cibefore a bus specific device for the function is created. However, when 11662306a36Sopenharmony_ciSRIOV is enabled, virtual function devices are created on the PCI bus. 11762306a36Sopenharmony_ciHence, function attribute should be configured before binding virtual 11862306a36Sopenharmony_cifunction device to the driver. For subfunctions, this means user should 11962306a36Sopenharmony_ciconfigure port function attribute before activating the port function. 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ciA user may set the hardware address of the function using 12262306a36Sopenharmony_ci`devlink port function set hw_addr` command. For Ethernet port function 12362306a36Sopenharmony_cithis means a MAC address. 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ciUsers may also set the RoCE capability of the function using 12662306a36Sopenharmony_ci`devlink port function set roce` command. 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ciUsers may also set the function as migratable using 12962306a36Sopenharmony_ci`devlink port function set migratable` command. 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ciUsers may also set the IPsec crypto capability of the function using 13262306a36Sopenharmony_ci`devlink port function set ipsec_crypto` command. 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ciUsers may also set the IPsec packet capability of the function using 13562306a36Sopenharmony_ci`devlink port function set ipsec_packet` command. 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ciFunction attributes 13862306a36Sopenharmony_ci=================== 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ciMAC address setup 14162306a36Sopenharmony_ci----------------- 14262306a36Sopenharmony_ciThe configured MAC address of the PCI VF/SF will be used by netdevice and rdma 14362306a36Sopenharmony_cidevice created for the PCI VF/SF. 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci- Get the MAC address of the VF identified by its unique devlink port index:: 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 14862306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 14962306a36Sopenharmony_ci function: 15062306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci- Set the MAC address of the VF identified by its unique devlink port index:: 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 15762306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 15862306a36Sopenharmony_ci function: 15962306a36Sopenharmony_ci hw_addr 00:11:22:33:44:55 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci- Get the MAC address of the SF identified by its unique devlink port index:: 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/32768 16462306a36Sopenharmony_ci pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 16562306a36Sopenharmony_ci function: 16662306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci- Set the MAC address of the SF identified by its unique devlink port index:: 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/32768 17362306a36Sopenharmony_ci pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 17462306a36Sopenharmony_ci function: 17562306a36Sopenharmony_ci hw_addr 00:00:00:00:88:88 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ciRoCE capability setup 17862306a36Sopenharmony_ci--------------------- 17962306a36Sopenharmony_ciNot all PCI VFs/SFs require RoCE capability. 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ciWhen RoCE capability is disabled, it saves system memory per PCI VF/SF. 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ciWhen user disables RoCE capability for a VF/SF, user application cannot send or 18462306a36Sopenharmony_cireceive any RoCE packets through this VF/SF and RoCE GID table for this PCI 18562306a36Sopenharmony_ciwill be empty. 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ciWhen RoCE capability is disabled in the device using port function attribute, 18862306a36Sopenharmony_ciVF/SF driver cannot override it. 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci- Get RoCE capability of the VF device:: 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 19362306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 19462306a36Sopenharmony_ci function: 19562306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 roce enable 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci- Set RoCE capability of the VF device:: 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci $ devlink port function set pci/0000:06:00.0/2 roce disable 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 20262306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 20362306a36Sopenharmony_ci function: 20462306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 roce disable 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_cimigratable capability setup 20762306a36Sopenharmony_ci--------------------------- 20862306a36Sopenharmony_ciLive migration is the process of transferring a live virtual machine 20962306a36Sopenharmony_cifrom one physical host to another without disrupting its normal 21062306a36Sopenharmony_cioperation. 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ciUser who want PCI VFs to be able to perform live migration need to 21362306a36Sopenharmony_ciexplicitly enable the VF migratable capability. 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ciWhen user enables migratable capability for a VF, and the HV binds the VF to VFIO driver 21662306a36Sopenharmony_ciwith migration support, the user can migrate the VM with this VF from one HV to a 21762306a36Sopenharmony_cidifferent one. 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ciHowever, when migratable capability is enable, device will disable features which cannot 22062306a36Sopenharmony_cibe migrated. Thus migratable cap can impose limitations on a VF so let the user decide. 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ciExample of LM with migratable function configuration: 22362306a36Sopenharmony_ci- Get migratable capability of the VF device:: 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 22662306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 22762306a36Sopenharmony_ci function: 22862306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 migratable disable 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci- Set migratable capability of the VF device:: 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci $ devlink port function set pci/0000:06:00.0/2 migratable enable 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 23562306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 23662306a36Sopenharmony_ci function: 23762306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 migratable enable 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci- Bind VF to VFIO driver with migration support:: 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci $ echo <pci_id> > /sys/bus/pci/devices/0000:08:00.0/driver/unbind 24262306a36Sopenharmony_ci $ echo mlx5_vfio_pci > /sys/bus/pci/devices/0000:08:00.0/driver_override 24362306a36Sopenharmony_ci $ echo <pci_id> > /sys/bus/pci/devices/0000:08:00.0/driver/bind 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ciAttach VF to the VM. 24662306a36Sopenharmony_ciStart the VM. 24762306a36Sopenharmony_ciPerform live migration. 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ciIPsec crypto capability setup 25062306a36Sopenharmony_ci----------------------------- 25162306a36Sopenharmony_ciWhen user enables IPsec crypto capability for a VF, user application can offload 25262306a36Sopenharmony_ciXFRM state crypto operation (Encrypt/Decrypt) to this VF. 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ciWhen IPsec crypto capability is disabled (default) for a VF, the XFRM state is 25562306a36Sopenharmony_ciprocessed in software by the kernel. 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci- Get IPsec crypto capability of the VF device:: 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 26062306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 26162306a36Sopenharmony_ci function: 26262306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 ipsec_crypto disabled 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci- Set IPsec crypto capability of the VF device:: 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci $ devlink port function set pci/0000:06:00.0/2 ipsec_crypto enable 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 26962306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 27062306a36Sopenharmony_ci function: 27162306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 ipsec_crypto enabled 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ciIPsec packet capability setup 27462306a36Sopenharmony_ci----------------------------- 27562306a36Sopenharmony_ciWhen user enables IPsec packet capability for a VF, user application can offload 27662306a36Sopenharmony_ciXFRM state and policy crypto operation (Encrypt/Decrypt) to this VF, as well as 27762306a36Sopenharmony_ciIPsec encapsulation. 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ciWhen IPsec packet capability is disabled (default) for a VF, the XFRM state and 28062306a36Sopenharmony_cipolicy is processed in software by the kernel. 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci- Get IPsec packet capability of the VF device:: 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 28562306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 28662306a36Sopenharmony_ci function: 28762306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 ipsec_packet disabled 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ci- Set IPsec packet capability of the VF device:: 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci $ devlink port function set pci/0000:06:00.0/2 ipsec_packet enable 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci $ devlink port show pci/0000:06:00.0/2 29462306a36Sopenharmony_ci pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 29562306a36Sopenharmony_ci function: 29662306a36Sopenharmony_ci hw_addr 00:00:00:00:00:00 ipsec_packet enabled 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ciSubfunction 29962306a36Sopenharmony_ci============ 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ciSubfunction is a lightweight function that has a parent PCI function on which 30262306a36Sopenharmony_ciit is deployed. Subfunction is created and deployed in unit of 1. Unlike 30362306a36Sopenharmony_ciSRIOV VFs, a subfunction doesn't require its own PCI virtual function. 30462306a36Sopenharmony_ciA subfunction communicates with the hardware through the parent PCI function. 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ciTo use a subfunction, 3 steps setup sequence is followed: 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci1) create - create a subfunction; 30962306a36Sopenharmony_ci2) configure - configure subfunction attributes; 31062306a36Sopenharmony_ci3) deploy - deploy the subfunction; 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ciSubfunction management is done using devlink port user interface. 31362306a36Sopenharmony_ciUser performs setup on the subfunction management device. 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci(1) Create 31662306a36Sopenharmony_ci---------- 31762306a36Sopenharmony_ciA subfunction is created using a devlink port interface. A user adds the 31862306a36Sopenharmony_cisubfunction by adding a devlink port of subfunction flavour. The devlink 31962306a36Sopenharmony_cikernel code calls down to subfunction management driver (devlink ops) and asks 32062306a36Sopenharmony_ciit to create a subfunction devlink port. Driver then instantiates the 32162306a36Sopenharmony_cisubfunction port and any associated objects such as health reporters and 32262306a36Sopenharmony_cirepresentor netdevice. 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ci(2) Configure 32562306a36Sopenharmony_ci------------- 32662306a36Sopenharmony_ciA subfunction devlink port is created but it is not active yet. That means the 32762306a36Sopenharmony_cientities are created on devlink side, the e-switch port representor is created, 32862306a36Sopenharmony_cibut the subfunction device itself is not created. A user might use e-switch port 32962306a36Sopenharmony_cirepresentor to do settings, putting it into bridge, adding TC rules, etc. A user 33062306a36Sopenharmony_cimight as well configure the hardware address (such as MAC address) of the 33162306a36Sopenharmony_cisubfunction while subfunction is inactive. 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci(3) Deploy 33462306a36Sopenharmony_ci---------- 33562306a36Sopenharmony_ciOnce a subfunction is configured, user must activate it to use it. Upon 33662306a36Sopenharmony_ciactivation, subfunction management driver asks the subfunction management 33762306a36Sopenharmony_cidevice to instantiate the subfunction device on particular PCI function. 33862306a36Sopenharmony_ciA subfunction device is created on the :ref:`Documentation/driver-api/auxiliary_bus.rst <auxiliary_bus>`. 33962306a36Sopenharmony_ciAt this point a matching subfunction driver binds to the subfunction's auxiliary device. 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ciRate object management 34262306a36Sopenharmony_ci====================== 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ciDevlink provides API to manage tx rates of single devlink port or a group. 34562306a36Sopenharmony_ciThis is done through rate objects, which can be one of the two types: 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci``leaf`` 34862306a36Sopenharmony_ci Represents a single devlink port; created/destroyed by the driver. Since leaf 34962306a36Sopenharmony_ci have 1to1 mapping to its devlink port, in user space it is referred as 35062306a36Sopenharmony_ci ``pci/<bus_addr>/<port_index>``; 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ci``node`` 35362306a36Sopenharmony_ci Represents a group of rate objects (leafs and/or nodes); created/deleted by 35462306a36Sopenharmony_ci request from the userspace; initially empty (no rate objects added). In 35562306a36Sopenharmony_ci userspace it is referred as ``pci/<bus_addr>/<node_name>``, where 35662306a36Sopenharmony_ci ``node_name`` can be any identifier, except decimal number, to avoid 35762306a36Sopenharmony_ci collisions with leafs. 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ciAPI allows to configure following rate object's parameters: 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci``tx_share`` 36262306a36Sopenharmony_ci Minimum TX rate value shared among all other rate objects, or rate objects 36362306a36Sopenharmony_ci that parts of the parent group, if it is a part of the same group. 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci``tx_max`` 36662306a36Sopenharmony_ci Maximum TX rate value. 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ci``tx_priority`` 36962306a36Sopenharmony_ci Allows for usage of strict priority arbiter among siblings. This 37062306a36Sopenharmony_ci arbitration scheme attempts to schedule nodes based on their priority 37162306a36Sopenharmony_ci as long as the nodes remain within their bandwidth limit. The higher the 37262306a36Sopenharmony_ci priority the higher the probability that the node will get selected for 37362306a36Sopenharmony_ci scheduling. 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ci``tx_weight`` 37662306a36Sopenharmony_ci Allows for usage of Weighted Fair Queuing arbitration scheme among 37762306a36Sopenharmony_ci siblings. This arbitration scheme can be used simultaneously with the 37862306a36Sopenharmony_ci strict priority. As a node is configured with a higher rate it gets more 37962306a36Sopenharmony_ci BW relative to its siblings. Values are relative like a percentage 38062306a36Sopenharmony_ci points, they basically tell how much BW should node take relative to 38162306a36Sopenharmony_ci its siblings. 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci``parent`` 38462306a36Sopenharmony_ci Parent node name. Parent node rate limits are considered as additional limits 38562306a36Sopenharmony_ci to all node children limits. ``tx_max`` is an upper limit for children. 38662306a36Sopenharmony_ci ``tx_share`` is a total bandwidth distributed among children. 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci``tx_priority`` and ``tx_weight`` can be used simultaneously. In that case 38962306a36Sopenharmony_cinodes with the same priority form a WFQ subgroup in the sibling group 39062306a36Sopenharmony_ciand arbitration among them is based on assigned weights. 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ciArbitration flow from the high level: 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci#. Choose a node, or group of nodes with the highest priority that stays 39562306a36Sopenharmony_ci within the BW limit and are not blocked. Use ``tx_priority`` as a 39662306a36Sopenharmony_ci parameter for this arbitration. 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci#. If group of nodes have the same priority perform WFQ arbitration on 39962306a36Sopenharmony_ci that subgroup. Use ``tx_weight`` as a parameter for this arbitration. 40062306a36Sopenharmony_ci 40162306a36Sopenharmony_ci#. Select the winner node, and continue arbitration flow among its children, 40262306a36Sopenharmony_ci until leaf node is reached, and the winner is established. 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ci#. If all the nodes from the highest priority sub-group are satisfied, or 40562306a36Sopenharmony_ci overused their assigned BW, move to the lower priority nodes. 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ciDriver implementations are allowed to support both or either rate object types 40862306a36Sopenharmony_ciand setting methods of their parameters. Additionally driver implementation 40962306a36Sopenharmony_cimay export nodes/leafs and their child-parent relationships. 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ciTerms and Definitions 41262306a36Sopenharmony_ci===================== 41362306a36Sopenharmony_ci 41462306a36Sopenharmony_ci.. list-table:: Terms and Definitions 41562306a36Sopenharmony_ci :widths: 22 90 41662306a36Sopenharmony_ci 41762306a36Sopenharmony_ci * - Term 41862306a36Sopenharmony_ci - Definitions 41962306a36Sopenharmony_ci * - ``PCI device`` 42062306a36Sopenharmony_ci - A physical PCI device having one or more PCI buses consists of one or 42162306a36Sopenharmony_ci more PCI controllers. 42262306a36Sopenharmony_ci * - ``PCI controller`` 42362306a36Sopenharmony_ci - A controller consists of potentially multiple physical functions, 42462306a36Sopenharmony_ci virtual functions and subfunctions. 42562306a36Sopenharmony_ci * - ``Port function`` 42662306a36Sopenharmony_ci - An object to manage the function of a port. 42762306a36Sopenharmony_ci * - ``Subfunction`` 42862306a36Sopenharmony_ci - A lightweight function that has parent PCI function on which it is 42962306a36Sopenharmony_ci deployed. 43062306a36Sopenharmony_ci * - ``Subfunction device`` 43162306a36Sopenharmony_ci - A bus device of the subfunction, usually on a auxiliary bus. 43262306a36Sopenharmony_ci * - ``Subfunction driver`` 43362306a36Sopenharmony_ci - A device driver for the subfunction auxiliary device. 43462306a36Sopenharmony_ci * - ``Subfunction management device`` 43562306a36Sopenharmony_ci - A PCI physical function that supports subfunction management. 43662306a36Sopenharmony_ci * - ``Subfunction management driver`` 43762306a36Sopenharmony_ci - A device driver for PCI physical function that supports 43862306a36Sopenharmony_ci subfunction management using devlink port interface. 43962306a36Sopenharmony_ci * - ``Subfunction host driver`` 44062306a36Sopenharmony_ci - A device driver for PCI physical function that hosts subfunction 44162306a36Sopenharmony_ci devices. In most cases it is same as subfunction management driver. When 44262306a36Sopenharmony_ci subfunction is used on external controller, subfunction management and 44362306a36Sopenharmony_ci host drivers are different. 444