343 lines · plain
1.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)2 3====================================4Marvell OcteonTx2 RVU Kernel Drivers5====================================6 7Copyright (c) 2020 Marvell International Ltd.8 9Contents10========11 12- `Overview`_13- `Drivers`_14- `Basic packet flow`_15- `Devlink health reporters`_16- `Quality of service`_17 18Overview19========20 21Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC maps HW22resources from the network, crypto and other functional blocks into23PCI-compatible physical and virtual functions. Each functional block24again has multiple local functions (LFs) for provisioning to PCI devices.25RVU supports multiple PCIe SRIOV physical functions (PFs) and virtual26functions (VFs). PF0 is called the administrative / admin function (AF)27and has privileges to provision RVU functional block's LFs to each of the28PF/VF.29 30RVU managed networking functional blocks31 - Network pool or buffer allocator (NPA)32 - Network interface controller (NIX)33 - Network parser CAM (NPC)34 - Schedule/Synchronize/Order unit (SSO)35 - Loopback interface (LBK)36 37RVU managed non-networking functional blocks38 - Crypto accelerator (CPT)39 - Scheduled timers unit (TIM)40 - Schedule/Synchronize/Order unit (SSO)41 Used for both networking and non networking usecases42 43Resource provisioning examples44 - A PF/VF with NIX-LF & NPA-LF resources works as a pure network device45 - A PF/VF with CPT-LF resource works as a pure crypto offload device.46 47RVU functional blocks are highly configurable as per software requirements.48 49Firmware setups following stuff before kernel boots50 - Enables required number of RVU PFs based on number of physical links.51 - Number of VFs per PF are either static or configurable at compile time.52 Based on config, firmware assigns VFs to each of the PFs.53 - Also assigns MSIX vectors to each of PF and VFs.54 - These are not changed after kernel boot.55 56Drivers57=======58 59Linux kernel will have multiple drivers registering to different PF and VFs60of RVU. Wrt networking there will be 3 flavours of drivers.61 62Admin Function driver63---------------------64 65As mentioned above RVU PF0 is called the admin function (AF), this driver66supports resource provisioning and configuration of functional blocks.67Doesn't handle any I/O. It sets up few basic stuff but most of the68funcionality is achieved via configuration requests from PFs and VFs.69 70PF/VFs communicates with AF via a shared memory region (mailbox). Upon71receiving requests AF does resource provisioning and other HW configuration.72AF is always attached to host kernel, but PFs and their VFs may be used by host73kernel itself, or attached to VMs or to userspace applications like74DPDK etc. So AF has to handle provisioning/configuration requests sent75by any device from any domain.76 77AF driver also interacts with underlying firmware to78 - Manage physical ethernet links ie CGX LMACs.79 - Retrieve information like speed, duplex, autoneg etc80 - Retrieve PHY EEPROM and stats.81 - Configure FEC, PAM modes82 - etc83 84From pure networking side AF driver supports following functionality.85 - Map a physical link to a RVU PF to which a netdev is registered.86 - Attach NIX and NPA block LFs to RVU PF/VF which provide buffer pools, RQs, SQs87 for regular networking functionality.88 - Flow control (pause frames) enable/disable/config.89 - HW PTP timestamping related config.90 - NPC parser profile config, basically how to parse pkt and what info to extract.91 - NPC extract profile config, what to extract from the pkt to match data in MCAM entries.92 - Manage NPC MCAM entries, upon request can frame and install requested packet forwarding rules.93 - Defines receive side scaling (RSS) algorithms.94 - Defines segmentation offload algorithms (eg TSO)95 - VLAN stripping, capture and insertion config.96 - SSO and TIM blocks config which provide packet scheduling support.97 - Debugfs support, to check current resource provising, current status of98 NPA pools, NIX RQ, SQ and CQs, various stats etc which helps in debugging issues.99 - And many more.100 101Physical Function driver102------------------------103 104This RVU PF handles IO, is mapped to a physical ethernet link and this105driver registers a netdev. This supports SR-IOV. As said above this driver106communicates with AF with a mailbox. To retrieve information from physical107links this driver talks to AF and AF gets that info from firmware and responds108back ie cannot talk to firmware directly.109 110Supports ethtool for configuring links, RSS, queue count, queue size,111flow control, ntuple filters, dump PHY EEPROM, config FEC etc.112 113Virtual Function driver114-----------------------115 116There are two types VFs, VFs that share the physical link with their parent117SR-IOV PF and the VFs which work in pairs using internal HW loopback channels (LBK).118 119Type1:120 - These VFs and their parent PF share a physical link and used for outside communication.121 - VFs cannot communicate with AF directly, they send mbox message to PF and PF122 forwards that to AF. AF after processing, responds back to PF and PF forwards123 the reply to VF.124 - From functionality point of view there is no difference between PF and VF as same type125 HW resources are attached to both. But user would be able to configure few stuff only126 from PF as PF is treated as owner/admin of the link.127 128Type2:129 - RVU PF0 ie admin function creates these VFs and maps them to loopback block's channels.130 - A set of two VFs (VF0 & VF1, VF2 & VF3 .. so on) works as a pair ie pkts sent out of131 VF0 will be received by VF1 and vice versa.132 - These VFs can be used by applications or virtual machines to communicate between them133 without sending traffic outside. There is no switch present in HW, hence the support134 for loopback VFs.135 - These communicate directly with AF (PF0) via mbox.136 137Except for the IO channels or links used for packet reception and transmission there is138no other difference between these VF types. AF driver takes care of IO channel mapping,139hence same VF driver works for both types of devices.140 141Basic packet flow142=================143 144Ingress145-------146 1471. CGX LMAC receives packet.1482. Forwards the packet to the NIX block.1493. Then submitted to NPC block for parsing and then MCAM lookup to get the destination RVU device.1504. NIX LF attached to the destination RVU device allocates a buffer from RQ mapped buffer pool of NPA block LF.1515. RQ may be selected by RSS or by configuring MCAM rule with a RQ number.1526. Packet is DMA'ed and driver is notified.153 154Egress155------156 1571. Driver prepares a send descriptor and submits to SQ for transmission.1582. The SQ is already configured (by AF) to transmit on a specific link/channel.1593. The SQ descriptor ring is maintained in buffers allocated from SQ mapped pool of NPA block LF.1604. NIX block transmits the pkt on the designated channel.1615. NPC MCAM entries can be installed to divert pkt onto a different channel.162 163Devlink health reporters164========================165 166NPA Reporters167-------------168The NPA reporters are responsible for reporting and recovering the following group of errors:169 1701. GENERAL events171 172 - Error due to operation of unmapped PF.173 - Error due to disabled alloc/free for other HW blocks (NIX, SSO, TIM, DPI and AURA).174 1752. ERROR events176 177 - Fault due to NPA_AQ_INST_S read or NPA_AQ_RES_S write.178 - AQ Doorbell Error.179 1803. RAS events181 182 - RAS Error Reporting for NPA_AQ_INST_S/NPA_AQ_RES_S.183 1844. RVU events185 186 - Error due to unmapped slot.187 188Sample Output::189 190 ~# devlink health191 pci/0002:01:00.0:192 reporter hw_npa_intr193 state healthy error 2872 recover 2872 last_dump_date 2020-12-10 last_dump_time 09:39:09 grace_period 0 auto_recover true auto_dump true194 reporter hw_npa_gen195 state healthy error 2872 recover 2872 last_dump_date 2020-12-11 last_dump_time 04:43:04 grace_period 0 auto_recover true auto_dump true196 reporter hw_npa_err197 state healthy error 2871 recover 2871 last_dump_date 2020-12-10 last_dump_time 09:39:17 grace_period 0 auto_recover true auto_dump true198 reporter hw_npa_ras199 state healthy error 0 recover 0 last_dump_date 2020-12-10 last_dump_time 09:32:40 grace_period 0 auto_recover true auto_dump true200 201Each reporter dumps the202 203 - Error Type204 - Error Register value205 - Reason in words206 207For example::208 209 ~# devlink health dump show pci/0002:01:00.0 reporter hw_npa_gen210 NPA_AF_GENERAL:211 NPA General Interrupt Reg : 1212 NIX0: free disabled RX213 ~# devlink health dump show pci/0002:01:00.0 reporter hw_npa_intr214 NPA_AF_RVU:215 NPA RVU Interrupt Reg : 1216 Unmap Slot Error217 ~# devlink health dump show pci/0002:01:00.0 reporter hw_npa_err218 NPA_AF_ERR:219 NPA Error Interrupt Reg : 4096220 AQ Doorbell Error221 222 223NIX Reporters224-------------225The NIX reporters are responsible for reporting and recovering the following group of errors:226 2271. GENERAL events228 229 - Receive mirror/multicast packet drop due to insufficient buffer.230 - SMQ Flush operation.231 2322. ERROR events233 234 - Memory Fault due to WQE read/write from multicast/mirror buffer.235 - Receive multicast/mirror replication list error.236 - Receive packet on an unmapped PF.237 - Fault due to NIX_AQ_INST_S read or NIX_AQ_RES_S write.238 - AQ Doorbell Error.239 2403. RAS events241 242 - RAS Error Reporting for NIX Receive Multicast/Mirror Entry Structure.243 - RAS Error Reporting for WQE/Packet Data read from Multicast/Mirror Buffer..244 - RAS Error Reporting for NIX_AQ_INST_S/NIX_AQ_RES_S.245 2464. RVU events247 248 - Error due to unmapped slot.249 250Sample Output::251 252 ~# ./devlink health253 pci/0002:01:00.0:254 reporter hw_npa_intr255 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true256 reporter hw_npa_gen257 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true258 reporter hw_npa_err259 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true260 reporter hw_npa_ras261 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true262 reporter hw_nix_intr263 state healthy error 1121 recover 1121 last_dump_date 2021-01-19 last_dump_time 05:42:26 grace_period 0 auto_recover true auto_dump true264 reporter hw_nix_gen265 state healthy error 949 recover 949 last_dump_date 2021-01-19 last_dump_time 05:42:43 grace_period 0 auto_recover true auto_dump true266 reporter hw_nix_err267 state healthy error 1147 recover 1147 last_dump_date 2021-01-19 last_dump_time 05:42:59 grace_period 0 auto_recover true auto_dump true268 reporter hw_nix_ras269 state healthy error 409 recover 409 last_dump_date 2021-01-19 last_dump_time 05:43:16 grace_period 0 auto_recover true auto_dump true270 271Each reporter dumps the272 273 - Error Type274 - Error Register value275 - Reason in words276 277For example::278 279 ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_intr280 NIX_AF_RVU:281 NIX RVU Interrupt Reg : 1282 Unmap Slot Error283 ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_gen284 NIX_AF_GENERAL:285 NIX General Interrupt Reg : 1286 Rx multicast pkt drop287 ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_err288 NIX_AF_ERR:289 NIX Error Interrupt Reg : 64290 Rx on unmapped PF_FUNC291 292 293Quality of service294==================295 296 297Hardware algorithms used in scheduling298--------------------------------------299 300octeontx2 silicon and CN10K transmit interface consists of five transmit levels301starting from SMQ/MDQ, TL4 to TL1. Each packet will traverse MDQ, TL4 to TL1302levels. Each level contains an array of queues to support scheduling and shaping.303The hardware uses the below algorithms depending on the priority of scheduler queues.304once the usercreates tc classes with different priorities, the driver configures305schedulers allocated to the class with specified priority along with rate-limiting306configuration.307 3081. Strict Priority309 310 - Once packets are submitted to MDQ, hardware picks all active MDQs having different priority311 using strict priority.312 3132. Round Robin314 315 - Active MDQs having the same priority level are chosen using round robin.316 317 318Setup HTB offload319-----------------320 3211. Enable HW TC offload on the interface::322 323 # ethtool -K <interface> hw-tc-offload on324 3252. Crate htb root::326 327 # tc qdisc add dev <interface> clsact328 # tc qdisc replace dev <interface> root handle 1: htb offload329 3303. Create tc classes with different priorities::331 332 # tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 1333 334 # tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 7335 3364. Create tc classes with same priorities and different quantum::337 338 # tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 2 quantum 409600339 340 # tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 2 quantum 188416341 342 # tc class add dev <interface> parent 1: classid 1:3 htb rate 10Gbit prio 2 quantum 32768343