282 lines · plain
1.. SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB2.. include:: <isonum.txt>3 4=========5Switchdev6=========7 8:Copyright: |copy| 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.9 10.. _mlx5_bridge_offload:11 12Bridge offload13==============14 15The mlx5 driver implements support for offloading bridge rules when in switchdev16mode. Linux bridge FDBs are automatically offloaded when mlx5 switchdev17representor is attached to bridge.18 19- Change device to switchdev mode::20 21 $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev22 23- Attach mlx5 switchdev representor 'enp8s0f0' to bridge netdev 'bridge1'::24 25 $ ip link set enp8s0f0 master bridge126 27VLANs28-----29 30Following bridge VLAN functions are supported by mlx5:31 32- VLAN filtering (including multiple VLANs per port)::33 34 $ ip link set bridge1 type bridge vlan_filtering 135 $ bridge vlan add dev enp8s0f0 vid 2-336 37- VLAN push on bridge ingress::38 39 $ bridge vlan add dev enp8s0f0 vid 3 pvid40 41- VLAN pop on bridge egress::42 43 $ bridge vlan add dev enp8s0f0 vid 3 untagged44 45Subfunction46===========47 48Subfunction which are spawned over the E-switch are created only with devlink49device, and by default all the SF auxiliary devices are disabled.50This will allow user to configure the SF before the SF have been fully probed,51which will save time.52 53Usage example:54 55- Create SF::56 57 $ devlink port add pci/0000:08:00.0 flavour pcisf pfnum 0 sfnum 1158 $ devlink port function set pci/0000:08:00.0/32768 hw_addr 00:00:00:00:00:11 state active59 60- Enable ETH auxiliary device::61 62 $ devlink dev param set auxiliary/mlx5_core.sf.1 name enable_eth value true cmode driverinit63 64- Now, in order to fully probe the SF, use devlink reload::65 66 $ devlink dev reload auxiliary/mlx5_core.sf.167 68mlx5 supports ETH,rdma and vdpa (vnet) auxiliary devices devlink params (see :ref:`Documentation/networking/devlink/devlink-params.rst <devlink_params_generic>`).69 70mlx5 supports subfunction management using devlink port (see :ref:`Documentation/networking/devlink/devlink-port.rst <devlink_port>`) interface.71 72A subfunction has its own function capabilities and its own resources. This73means a subfunction has its own dedicated queues (txq, rxq, cq, eq). These74queues are neither shared nor stolen from the parent PCI function.75 76When a subfunction is RDMA capable, it has its own QP1, GID table, and RDMA77resources neither shared nor stolen from the parent PCI function.78 79A subfunction has a dedicated window in PCI BAR space that is not shared80with the other subfunctions or the parent PCI function. This ensures that all81devices (netdev, rdma, vdpa, etc.) of the subfunction accesses only assigned82PCI BAR space.83 84A subfunction supports eswitch representation through which it supports tc85offloads. The user configures eswitch to send/receive packets from/to86the subfunction port.87 88Subfunctions share PCI level resources such as PCI MSI-X IRQs with89other subfunctions and/or with its parent PCI function.90 91Example mlx5 software, system, and device view::92 93 _______94 | admin |95 | user |----------96 |_______| |97 | |98 ____|____ __|______ _________________99 | | | | | |100 | devlink | | tc tool | | user |101 | tool | |_________| | applications |102 |_________| | |_________________|103 | | | |104 | | | | Userspace105 +---------|-------------|-------------------|----------|--------------------+106 | | +----------+ +----------+ Kernel107 | | | netdev | | rdma dev |108 | | +----------+ +----------+109 (devlink port add/del | ^ ^110 port function set) | | |111 | | +---------------|112 _____|___ | | _______|_______113 | | | | | mlx5 class |114 | devlink | +------------+ | | drivers |115 | kernel | | rep netdev | | |(mlx5_core,ib) |116 |_________| +------------+ | |_______________|117 | | | ^118 (devlink ops) | | (probe/remove)119 _________|________ | | ____|________120 | subfunction | | +---------------+ | subfunction |121 | management driver|----- | subfunction |---| driver |122 | (mlx5_core) | | auxiliary dev | | (mlx5_core) |123 |__________________| +---------------+ |_____________|124 | ^125 (sf add/del, vhca events) |126 | (device add/del)127 _____|____ ____|________128 | | | subfunction |129 | PCI NIC |--- activate/deactivate events--->| host driver |130 |__________| | (mlx5_core) |131 |_____________|132 133Subfunction is created using devlink port interface.134 135- Change device to switchdev mode::136 137 $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev138 139- Add a devlink port of subfunction flavour::140 141 $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88142 pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false143 function:144 hw_addr 00:00:00:00:00:00 state inactive opstate detached145 146- Show a devlink port of the subfunction::147 148 $ devlink port show pci/0000:06:00.0/32768149 pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88150 function:151 hw_addr 00:00:00:00:00:00 state inactive opstate detached152 153- Delete a devlink port of subfunction after use::154 155 $ devlink port del pci/0000:06:00.0/32768156 157Function attributes158===================159 160The mlx5 driver provides a mechanism to setup PCI VF/SF function attributes in161a unified way for SmartNIC and non-SmartNIC.162 163This is supported only when the eswitch mode is set to switchdev. Port function164configuration of the PCI VF/SF is supported through devlink eswitch port.165 166Port function attributes should be set before PCI VF/SF is enumerated by the167driver.168 169MAC address setup170-----------------171 172mlx5 driver support devlink port function attr mechanism to setup MAC173address. (refer to Documentation/networking/devlink/devlink-port.rst)174 175RoCE capability setup176~~~~~~~~~~~~~~~~~~~~~177Not all mlx5 PCI devices/SFs require RoCE capability.178 179When RoCE capability is disabled, it saves 1 Mbytes worth of system memory per180PCI devices/SF.181 182mlx5 driver support devlink port function attr mechanism to setup RoCE183capability. (refer to Documentation/networking/devlink/devlink-port.rst)184 185migratable capability setup186~~~~~~~~~~~~~~~~~~~~~~~~~~~187User who wants mlx5 PCI VFs to be able to perform live migration need to188explicitly enable the VF migratable capability.189 190mlx5 driver support devlink port function attr mechanism to setup migratable191capability. (refer to Documentation/networking/devlink/devlink-port.rst)192 193IPsec crypto capability setup194~~~~~~~~~~~~~~~~~~~~~~~~~~~~~195User who wants mlx5 PCI VFs to be able to perform IPsec crypto offloading need196to explicitly enable the VF ipsec_crypto capability. Enabling IPsec capability197for VFs is supported starting with ConnectX6dx devices and above. When a VF has198IPsec capability enabled, any IPsec offloading is blocked on the PF.199 200mlx5 driver support devlink port function attr mechanism to setup ipsec_crypto201capability. (refer to Documentation/networking/devlink/devlink-port.rst)202 203IPsec packet capability setup204~~~~~~~~~~~~~~~~~~~~~~~~~~~~~205User who wants mlx5 PCI VFs to be able to perform IPsec packet offloading need206to explicitly enable the VF ipsec_packet capability. Enabling IPsec capability207for VFs is supported starting with ConnectX6dx devices and above. When a VF has208IPsec capability enabled, any IPsec offloading is blocked on the PF.209 210mlx5 driver support devlink port function attr mechanism to setup ipsec_packet211capability. (refer to Documentation/networking/devlink/devlink-port.rst)212 213SF state setup214--------------215 216To use the SF, the user must activate the SF using the SF function state217attribute.218 219- Get the state of the SF identified by its unique devlink port index::220 221 $ devlink port show ens2f0npf0sf88222 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false223 function:224 hw_addr 00:00:00:00:88:88 state inactive opstate detached225 226- Activate the function and verify its state is active::227 228 $ devlink port function set ens2f0npf0sf88 state active229 230 $ devlink port show ens2f0npf0sf88231 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false232 function:233 hw_addr 00:00:00:00:88:88 state active opstate detached234 235Upon function activation, the PF driver instance gets the event from the device236that a particular SF was activated. It's the cue to put the device on bus, probe237it and instantiate the devlink instance and class specific auxiliary devices238for it.239 240- Show the auxiliary device and port of the subfunction::241 242 $ devlink dev show243 devlink dev show auxiliary/mlx5_core.sf.4244 245 $ devlink port show auxiliary/mlx5_core.sf.4/1246 auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false247 248 $ rdma link show mlx5_0/1249 link mlx5_0/1 state ACTIVE physical_state LINK_UP netdev p0sf88250 251 $ rdma dev show252 8: rocep6s0f1: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d113 sys_image_guid 248a:0703:00b3:d112253 13: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112254 255- Subfunction auxiliary device and class device hierarchy::256 257 mlx5_core.sf.4258 (subfunction auxiliary device)259 /\260 / \261 / \262 / \263 / \264 mlx5_core.eth.4 mlx5_core.rdma.4265 (sf eth aux dev) (sf rdma aux dev)266 | |267 | |268 p0sf88 mlx5_0269 (sf netdev) (sf rdma device)270 271Additionally, the SF port also gets the event when the driver attaches to the272auxiliary device of the subfunction. This results in changing the operational273state of the function. This provides visibility to the user to decide when is it274safe to delete the SF port for graceful termination of the subfunction.275 276- Show the SF port operational state::277 278 $ devlink port show ens2f0npf0sf88279 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false280 function:281 hw_addr 00:00:00:00:88:88 state active opstate attached282