1.. SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2 3================================================= 4Mellanox ConnectX(R) mlx5 core VPI Network Driver 5================================================= 6 7Copyright (c) 2019, Mellanox Technologies LTD. 8 9Contents 10======== 11 12- `Enabling the driver and kconfig options`_ 13- `Devlink info`_ 14- `Devlink parameters`_ 15- `mlx5 subfunction`_ 16- `mlx5 function attributes`_ 17- `Devlink health reporters`_ 18- `mlx5 tracepoints`_ 19 20Enabling the driver and kconfig options 21======================================= 22 23| mlx5 core is modular and most of the major mlx5 core driver features can be selected (compiled in/out) 24| at build time via kernel Kconfig flags. 25| Basic features, ethernet net device rx/tx offloads and XDP, are available with the most basic flags 26| CONFIG_MLX5_CORE=y/m and CONFIG_MLX5_CORE_EN=y. 27| For the list of advanced features please see below. 28 29**CONFIG_MLX5_CORE=(y/m/n)** (module mlx5_core.ko) 30 31| The driver can be enabled by choosing CONFIG_MLX5_CORE=y/m in kernel config. 32| This will provide mlx5 core driver for mlx5 ulps to interface with (mlx5e, mlx5_ib). 33 34 35**CONFIG_MLX5_CORE_EN=(y/n)** 36 37| Choosing this option will allow basic ethernet netdevice support with all of the standard rx/tx offloads. 38| mlx5e is the mlx5 ulp driver which provides netdevice kernel interface, when chosen, mlx5e will be 39| built-in into mlx5_core.ko. 40 41 42**CONFIG_MLX5_EN_ARFS=(y/n)** 43 44| Enables Hardware-accelerated receive flow steering (arfs) support, and ntuple filtering. 45| https://community.mellanox.com/s/article/howto-configure-arfs-on-connectx-4 46 47 48**CONFIG_MLX5_EN_RXNFC=(y/n)** 49 50| Enables ethtool receive network flow classification, which allows user defined 51| flow rules to direct traffic into arbitrary rx queue via ethtool set/get_rxnfc API. 52 53 54**CONFIG_MLX5_CORE_EN_DCB=(y/n)**: 55 56| Enables `Data Center Bridging (DCB) Support <https://community.mellanox.com/s/article/howto-auto-config-pfc-and-ets-on-connectx-4-via-lldp-dcbx>`_. 57 58 59**CONFIG_MLX5_MPFS=(y/n)** 60 61| Ethernet Multi-Physical Function Switch (MPFS) support in ConnectX NIC. 62| MPFs is required for when `Multi-Host <http://www.mellanox.com/page/multihost>`_ configuration is enabled to allow passing 63| user configured unicast MAC addresses to the requesting PF. 64 65 66**CONFIG_MLX5_ESWITCH=(y/n)** 67 68| Ethernet SRIOV E-Switch support in ConnectX NIC. E-Switch provides internal SRIOV packet steering 69| and switching for the enabled VFs and PF in two available modes: 70| 1) `Legacy SRIOV mode (L2 mac vlan steering based) <https://community.mellanox.com/s/article/howto-configure-sr-iov-for-connectx-4-connectx-5-with-kvm--ethernet-x>`_. 71| 2) `Switchdev mode (eswitch offloads) <https://www.mellanox.com/related-docs/prod_software/ASAP2_Hardware_Offloading_for_vSwitches_User_Manual_v4.4.pdf>`_. 72 73 74**CONFIG_MLX5_CORE_IPOIB=(y/n)** 75 76| IPoIB offloads & acceleration support. 77| Requires CONFIG_MLX5_CORE_EN to provide an accelerated interface for the rdma 78| IPoIB ulp netdevice. 79 80 81**CONFIG_MLX5_FPGA=(y/n)** 82 83| Build support for the Innova family of network cards by Mellanox Technologies. 84| Innova network cards are comprised of a ConnectX chip and an FPGA chip on one board. 85| If you select this option, the mlx5_core driver will include the Innova FPGA core and allow 86| building sandbox-specific client drivers. 87 88 89**CONFIG_MLX5_EN_IPSEC=(y/n)** 90 91| Enables `IPSec XFRM cryptography-offload accelaration <http://www.mellanox.com/related-docs/prod_software/Mellanox_Innova_IPsec_Ethernet_Adapter_Card_User_Manual.pdf>`_. 92 93**CONFIG_MLX5_EN_TLS=(y/n)** 94 95| TLS cryptography-offload accelaration. 96 97 98**CONFIG_MLX5_INFINIBAND=(y/n/m)** (module mlx5_ib.ko) 99 100| Provides low-level InfiniBand/RDMA and `RoCE <https://community.mellanox.com/s/article/recommended-network-configuration-examples-for-roce-deployment>`_ support. 101 102**CONFIG_MLX5_SF=(y/n)** 103 104| Build support for subfunction. 105| Subfunctons are more light weight than PCI SRIOV VFs. Choosing this option 106| will enable support for creating subfunction devices. 107 108**External options** ( Choose if the corresponding mlx5 feature is required ) 109 110- CONFIG_PTP_1588_CLOCK: When chosen, mlx5 ptp support will be enabled 111- CONFIG_VXLAN: When chosen, mlx5 vxlan support will be enabled. 112- CONFIG_MLXFW: When chosen, mlx5 firmware flashing support will be enabled (via devlink and ethtool). 113 114Devlink info 115============ 116 117The devlink info reports the running and stored firmware versions on device. 118It also prints the device PSID which represents the HCA board type ID. 119 120User command example:: 121 122 $ devlink dev info pci/0000:00:06.0 123 pci/0000:00:06.0: 124 driver mlx5_core 125 versions: 126 fixed: 127 fw.psid MT_0000000009 128 running: 129 fw.version 16.26.0100 130 stored: 131 fw.version 16.26.0100 132 133Devlink parameters 134================== 135 136flow_steering_mode: Device flow steering mode 137--------------------------------------------- 138The flow steering mode parameter controls the flow steering mode of the driver. 139Two modes are supported: 1401. 'dmfs' - Device managed flow steering. 1412. 'smfs - Software/Driver managed flow steering. 142 143In DMFS mode, the HW steering entities are created and managed through the 144Firmware. 145In SMFS mode, the HW steering entities are created and managed though by 146the driver directly into Hardware without firmware intervention. 147 148SMFS mode is faster and provides better rule inserstion rate compared to default DMFS mode. 149 150User command examples: 151 152- Set SMFS flow steering mode:: 153 154 $ devlink dev param set pci/0000:06:00.0 name flow_steering_mode value "smfs" cmode runtime 155 156- Read device flow steering mode:: 157 158 $ devlink dev param show pci/0000:06:00.0 name flow_steering_mode 159 pci/0000:06:00.0: 160 name flow_steering_mode type driver-specific 161 values: 162 cmode runtime value smfs 163 164enable_roce: RoCE enablement state 165---------------------------------- 166RoCE enablement state controls driver support for RoCE traffic. 167When RoCE is disabled, there is no gid table, only raw ethernet QPs are supported and traffic on the well known UDP RoCE port is handled as raw ethernet traffic. 168 169To change RoCE enablement state a user must change the driverinit cmode value and run devlink reload. 170 171User command examples: 172 173- Disable RoCE:: 174 175 $ devlink dev param set pci/0000:06:00.0 name enable_roce value false cmode driverinit 176 $ devlink dev reload pci/0000:06:00.0 177 178- Read RoCE enablement state:: 179 180 $ devlink dev param show pci/0000:06:00.0 name enable_roce 181 pci/0000:06:00.0: 182 name enable_roce type generic 183 values: 184 cmode driverinit value true 185 186esw_port_metadata: Eswitch port metadata state 187---------------------------------------------- 188When applicable, disabling Eswitch metadata can increase packet rate 189up to 20% depending on the use case and packet sizes. 190 191Eswitch port metadata state controls whether to internally tag packets with 192metadata. Metadata tagging must be enabled for multi-port RoCE, failover 193between representors and stacked devices. 194By default metadata is enabled on the supported devices in E-switch. 195Metadata is applicable only for E-switch in switchdev mode and 196users may disable it when NONE of the below use cases will be in use: 1971. HCA is in Dual/multi-port RoCE mode. 1982. VF/SF representor bonding (Usually used for Live migration) 1993. Stacked devices 200 201When metadata is disabled, the above use cases will fail to initialize if 202users try to enable them. 203 204- Show eswitch port metadata:: 205 206 $ devlink dev param show pci/0000:06:00.0 name esw_port_metadata 207 pci/0000:06:00.0: 208 name esw_port_metadata type driver-specific 209 values: 210 cmode runtime value true 211 212- Disable eswitch port metadata:: 213 214 $ devlink dev param set pci/0000:06:00.0 name esw_port_metadata value false cmode runtime 215 216- Change eswitch mode to switchdev mode where after choosing the metadata value:: 217 218 $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev 219 220mlx5 subfunction 221================ 222mlx5 supports subfunction management using devlink port (see :ref:`Documentation/networking/devlink/devlink-port.rst <devlink_port>`) interface. 223 224A Subfunction has its own function capabilities and its own resources. This 225means a subfunction has its own dedicated queues (txq, rxq, cq, eq). These 226queues are neither shared nor stolen from the parent PCI function. 227 228When a subfunction is RDMA capable, it has its own QP1, GID table and rdma 229resources neither shared nor stolen from the parent PCI function. 230 231A subfunction has a dedicated window in PCI BAR space that is not shared 232with ther other subfunctions or the parent PCI function. This ensures that all 233devices (netdev, rdma, vdpa etc.) of the subfunction accesses only assigned 234PCI BAR space. 235 236A Subfunction supports eswitch representation through which it supports tc 237offloads. The user configures eswitch to send/receive packets from/to 238the subfunction port. 239 240Subfunctions share PCI level resources such as PCI MSI-X IRQs with 241other subfunctions and/or with its parent PCI function. 242 243Example mlx5 software, system and device view:: 244 245 _______ 246 | admin | 247 | user |---------- 248 |_______| | 249 | | 250 ____|____ __|______ _________________ 251 | | | | | | 252 | devlink | | tc tool | | user | 253 | tool | |_________| | applications | 254 |_________| | |_________________| 255 | | | | 256 | | | | Userspace 257 +---------|-------------|-------------------|----------|--------------------+ 258 | | +----------+ +----------+ Kernel 259 | | | netdev | | rdma dev | 260 | | +----------+ +----------+ 261 (devlink port add/del | ^ ^ 262 port function set) | | | 263 | | +---------------| 264 _____|___ | | _______|_______ 265 | | | | | mlx5 class | 266 | devlink | +------------+ | | drivers | 267 | kernel | | rep netdev | | |(mlx5_core,ib) | 268 |_________| +------------+ | |_______________| 269 | | | ^ 270 (devlink ops) | | (probe/remove) 271 _________|________ | | ____|________ 272 | subfunction | | +---------------+ | subfunction | 273 | management driver|----- | subfunction |---| driver | 274 | (mlx5_core) | | auxiliary dev | | (mlx5_core) | 275 |__________________| +---------------+ |_____________| 276 | ^ 277 (sf add/del, vhca events) | 278 | (device add/del) 279 _____|____ ____|________ 280 | | | subfunction | 281 | PCI NIC |---- activate/deactive events---->| host driver | 282 |__________| | (mlx5_core) | 283 |_____________| 284 285Subfunction is created using devlink port interface. 286 287- Change device to switchdev mode:: 288 289 $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev 290 291- Add a devlink port of subfunction flaovur:: 292 293 $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88 294 pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false 295 function: 296 hw_addr 00:00:00:00:00:00 state inactive opstate detached 297 298- Show a devlink port of the subfunction:: 299 300 $ devlink port show pci/0000:06:00.0/32768 301 pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 302 function: 303 hw_addr 00:00:00:00:00:00 state inactive opstate detached 304 305- Delete a devlink port of subfunction after use:: 306 307 $ devlink port del pci/0000:06:00.0/32768 308 309mlx5 function attributes 310======================== 311The mlx5 driver provides a mechanism to setup PCI VF/SF function attributes in 312a unified way for SmartNIC and non-SmartNIC. 313 314This is supported only when the eswitch mode is set to switchdev. Port function 315configuration of the PCI VF/SF is supported through devlink eswitch port. 316 317Port function attributes should be set before PCI VF/SF is enumerated by the 318driver. 319 320MAC address setup 321----------------- 322mlx5 driver provides mechanism to setup the MAC address of the PCI VF/SF. 323 324The configured MAC address of the PCI VF/SF will be used by netdevice and rdma 325device created for the PCI VF/SF. 326 327- Get the MAC address of the VF identified by its unique devlink port index:: 328 329 $ devlink port show pci/0000:06:00.0/2 330 pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 331 function: 332 hw_addr 00:00:00:00:00:00 333 334- Set the MAC address of the VF identified by its unique devlink port index:: 335 336 $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 337 338 $ devlink port show pci/0000:06:00.0/2 339 pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 340 function: 341 hw_addr 00:11:22:33:44:55 342 343- Get the MAC address of the SF identified by its unique devlink port index:: 344 345 $ devlink port show pci/0000:06:00.0/32768 346 pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 347 function: 348 hw_addr 00:00:00:00:00:00 349 350- Set the MAC address of the VF identified by its unique devlink port index:: 351 352 $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 353 354 $ devlink port show pci/0000:06:00.0/32768 355 pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcivf pfnum 0 sfnum 88 356 function: 357 hw_addr 00:00:00:00:88:88 358 359SF state setup 360-------------- 361To use the SF, the user must active the SF using the SF function state 362attribute. 363 364- Get the state of the SF identified by its unique devlink port index:: 365 366 $ devlink port show ens2f0npf0sf88 367 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false 368 function: 369 hw_addr 00:00:00:00:88:88 state inactive opstate detached 370 371- Activate the function and verify its state is active:: 372 373 $ devlink port function set ens2f0npf0sf88 state active 374 375 $ devlink port show ens2f0npf0sf88 376 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false 377 function: 378 hw_addr 00:00:00:00:88:88 state active opstate detached 379 380Upon function activation, the PF driver instance gets the event from the device 381that a particular SF was activated. It's the cue to put the device on bus, probe 382it and instantiate the devlink instance and class specific auxiliary devices 383for it. 384 385- Show the auxiliary device and port of the subfunction:: 386 387 $ devlink dev show 388 devlink dev show auxiliary/mlx5_core.sf.4 389 390 $ devlink port show auxiliary/mlx5_core.sf.4/1 391 auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false 392 393 $ rdma link show mlx5_0/1 394 link mlx5_0/1 state ACTIVE physical_state LINK_UP netdev p0sf88 395 396 $ rdma dev show 397 8: rocep6s0f1: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d113 sys_image_guid 248a:0703:00b3:d112 398 13: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112 399 400- Subfunction auxiliary device and class device hierarchy:: 401 402 mlx5_core.sf.4 403 (subfunction auxiliary device) 404 /\ 405 / \ 406 / \ 407 / \ 408 / \ 409 mlx5_core.eth.4 mlx5_core.rdma.4 410 (sf eth aux dev) (sf rdma aux dev) 411 | | 412 | | 413 p0sf88 mlx5_0 414 (sf netdev) (sf rdma device) 415 416Additionally, the SF port also gets the event when the driver attaches to the 417auxiliary device of the subfunction. This results in changing the operational 418state of the function. This provides visiblity to the user to decide when is it 419safe to delete the SF port for graceful termination of the subfunction. 420 421- Show the SF port operational state:: 422 423 $ devlink port show ens2f0npf0sf88 424 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false 425 function: 426 hw_addr 00:00:00:00:88:88 state active opstate attached 427 428Devlink health reporters 429======================== 430 431tx reporter 432----------- 433The tx reporter is responsible for reporting and recovering of the following two error scenarios: 434 435- TX timeout 436 Report on kernel tx timeout detection. 437 Recover by searching lost interrupts. 438- TX error completion 439 Report on error tx completion. 440 Recover by flushing the TX queue and reset it. 441 442TX reporter also support on demand diagnose callback, on which it provides 443real time information of its send queues status. 444 445User commands examples: 446 447- Diagnose send queues status:: 448 449 $ devlink health diagnose pci/0000:82:00.0 reporter tx 450 451NOTE: This command has valid output only when interface is up, otherwise the command has empty output. 452 453- Show number of tx errors indicated, number of recover flows ended successfully, 454 is autorecover enabled and graceful period from last recover:: 455 456 $ devlink health show pci/0000:82:00.0 reporter tx 457 458rx reporter 459----------- 460The rx reporter is responsible for reporting and recovering of the following two error scenarios: 461 462- RX queues initialization (population) timeout 463 RX queues descriptors population on ring initialization is done in 464 napi context via triggering an irq, in case of a failure to get 465 the minimum amount of descriptors, a timeout would occur and it 466 could be recoverable by polling the EQ (Event Queue). 467- RX completions with errors (reported by HW on interrupt context) 468 Report on rx completion error. 469 Recover (if needed) by flushing the related queue and reset it. 470 471RX reporter also supports on demand diagnose callback, on which it 472provides real time information of its receive queues status. 473 474- Diagnose rx queues status, and corresponding completion queue:: 475 476 $ devlink health diagnose pci/0000:82:00.0 reporter rx 477 478NOTE: This command has valid output only when interface is up, otherwise the command has empty output. 479 480- Show number of rx errors indicated, number of recover flows ended successfully, 481 is autorecover enabled and graceful period from last recover:: 482 483 $ devlink health show pci/0000:82:00.0 reporter rx 484 485fw reporter 486----------- 487The fw reporter implements diagnose and dump callbacks. 488It follows symptoms of fw error such as fw syndrome by triggering 489fw core dump and storing it into the dump buffer. 490The fw reporter diagnose command can be triggered any time by the user to check 491current fw status. 492 493User commands examples: 494 495- Check fw heath status:: 496 497 $ devlink health diagnose pci/0000:82:00.0 reporter fw 498 499- Read FW core dump if already stored or trigger new one:: 500 501 $ devlink health dump show pci/0000:82:00.0 reporter fw 502 503NOTE: This command can run only on the PF which has fw tracer ownership, 504running it on other PF or any VF will return "Operation not permitted". 505 506fw fatal reporter 507----------------- 508The fw fatal reporter implements dump and recover callbacks. 509It follows fatal errors indications by CR-space dump and recover flow. 510The CR-space dump uses vsc interface which is valid even if the FW command 511interface is not functional, which is the case in most FW fatal errors. 512The recover function runs recover flow which reloads the driver and triggers fw 513reset if needed. 514 515User commands examples: 516 517- Run fw recover flow manually:: 518 519 $ devlink health recover pci/0000:82:00.0 reporter fw_fatal 520 521- Read FW CR-space dump if already strored or trigger new one:: 522 523 $ devlink health dump show pci/0000:82:00.1 reporter fw_fatal 524 525NOTE: This command can run only on PF. 526 527mlx5 tracepoints 528================ 529 530mlx5 driver provides internal trace points for tracking and debugging using 531kernel tracepoints interfaces (refer to Documentation/trace/ftrace.rst). 532 533For the list of support mlx5 events check /sys/kernel/debug/tracing/events/mlx5/ 534 535tc and eswitch offloads tracepoints: 536 537- mlx5e_configure_flower: trace flower filter actions and cookies offloaded to mlx5:: 538 539 $ echo mlx5:mlx5e_configure_flower >> /sys/kernel/debug/tracing/set_event 540 $ cat /sys/kernel/debug/tracing/trace 541 ... 542 tc-6535 [019] ...1 2672.404466: mlx5e_configure_flower: cookie=0000000067874a55 actions= REDIRECT 543 544- mlx5e_delete_flower: trace flower filter actions and cookies deleted from mlx5:: 545 546 $ echo mlx5:mlx5e_delete_flower >> /sys/kernel/debug/tracing/set_event 547 $ cat /sys/kernel/debug/tracing/trace 548 ... 549 tc-6569 [010] .N.1 2686.379075: mlx5e_delete_flower: cookie=0000000067874a55 actions= NULL 550 551- mlx5e_stats_flower: trace flower stats request:: 552 553 $ echo mlx5:mlx5e_stats_flower >> /sys/kernel/debug/tracing/set_event 554 $ cat /sys/kernel/debug/tracing/trace 555 ... 556 tc-6546 [010] ...1 2679.704889: mlx5e_stats_flower: cookie=0000000060eb3d6a bytes=0 packets=0 lastused=4295560217 557 558- mlx5e_tc_update_neigh_used_value: trace tunnel rule neigh update value offloaded to mlx5:: 559 560 $ echo mlx5:mlx5e_tc_update_neigh_used_value >> /sys/kernel/debug/tracing/set_event 561 $ cat /sys/kernel/debug/tracing/trace 562 ... 563 kworker/u48:4-8806 [009] ...1 55117.882428: mlx5e_tc_update_neigh_used_value: netdev: ens1f0 IPv4: 1.1.1.10 IPv6: ::ffff:1.1.1.10 neigh_used=1 564 565- mlx5e_rep_neigh_update: trace neigh update tasks scheduled due to neigh state change events:: 566 567 $ echo mlx5:mlx5e_rep_neigh_update >> /sys/kernel/debug/tracing/set_event 568 $ cat /sys/kernel/debug/tracing/trace 569 ... 570 kworker/u48:7-2221 [009] ...1 1475.387435: mlx5e_rep_neigh_update: netdev: ens1f0 MAC: 24:8a:07:9a:17:9a IPv4: 1.1.1.10 IPv6: ::ffff:1.1.1.10 neigh_connected=1 571