← Documents Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst GitHub 원문 ↗

Linux 6.18.37 · Networking

Marvell OcteonTx2 RVU Kernel Drivers

OcteonTX2 RVU의 PF/VF resource model, AF·PF·VF driver, NPA/NIX health reporter, QoS와 representor offload를 설명합니다.

Source pathDocumentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

octeontx2.rst:1-433

OcteonTX2 RVU는 network와 crypto block의 Local Function을 PCI PF/VF에 조합해 필요한 device 역할을 만듭니다. PF0의 AF가 resource와 link configuration의 control plane을 맡고, PF/VF driver는 mailbox를 통해 AF에 요청하며 packet I/O는 NIX·NPA·NPC pipeline을 이용합니다.

RVU resource 조합
Resource역할
NPA-LFbuffer pool과 allocator
NIX-LFnetwork I/O queue와 interface
NPCpacket parse와 MCAM classification
NIX-LF + NPA-LFnetwork device
CPT-LFcrypto offload device
SSO/TIMpacket scheduling과 timer
LBK내부 loopback VF channel

functional block LF 조합에 따라 PCI function의 역할이 달라집니다.

AF·PF·VF driver 역할
DriverI/O주요 책임AF 통신
AF(PF0)직접 처리 안 함LF provisioning, hardware·firmware 구성mailbox server
PFphysical link I/Onetdev, SR-IOV, ethtool직접 mailbox
Type 1 VFPF와 link 공유외부 통신PF를 거쳐 AF
Type 2 VFLBK pair내부 VM·application 통신AF와 직접 mailbox

control plane과 I/O 책임을 구분합니다.

Ingress packet path
CGX LMAC 수신NIXNPC parseMCAM destination lookupNPA buffer allocateRSS/MCAM으로 RQ 선택DMAdriver 통지

classification 뒤 destination RVU의 buffer와 RQ를 선택합니다.

Egress packet path
driver send descriptorSQ submitNPA SQ pool의 descriptor ringNIX transmit지정 channel
NPC MCAM rule다른 channel로 divert 가능

AF가 미리 구성한 SQ와 channel을 따라 packet이 나갑니다.

NPA·NIX health reporter
GroupNPANIX
GENERALunmapped PF, alloc/free disabledmirror/multicast drop, SMQ flush
ERRORNPA AQ fault, doorbellWQE·replication·NIX AQ fault
RASNPA AQ structuremirror entry, WQE/data, NIX AQ
RVUunmapped slotunmapped slot

두 block이 공통으로 제공하는 reporter group과 차이를 요약합니다.

QoS scheduler 선택
TC class 관계Algorithm설정 기준
서로 다른 priorityStrict Priority`prio` 값
같은 priorityRound Robin`quantum` 값
공통HTB hardware offload`rate`와 scheduler shaping

MDQ priority와 quantum이 hardware scheduling 방식을 결정합니다.

Representor loopback path
representee transmitNPC MCAM matchMAC 대신 hardware LBKNPC MCAM 재일치representor receive
representor transmitNPC MCAM matchhardware LBKrepresentee receive

built-in L2 switch 대신 NPC MCAM filter와 LBK를 사용합니다.

Representor 관리
작업Interface·command
생성`devlink ... mode switchdev`
목록`ip link show`, `devlink port`
삭제`devlink ... mode legacy`
MAC 설정`devlink port function set ... hw_addr`
TC dropflower + `skip_sw action drop`
VLAN pop·redirectflower + `vlan pop` + `mirred redirect`

생성, 삭제와 function configuration command의 관계입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
3 ====================================
4 Marvell OcteonTx2 RVU Kernel Drivers
5 ====================================
6
7 Copyright (c) 2020 Marvell International Ltd.
8
9 Contents
10 ========
11
12 - `Overview`_
13 - `Drivers`_
14 - `Basic packet flow`_
15 - `Devlink health reporters`_
16 - `Quality of service`_
17 - `RVU representors`_
18
19 Overview
20 ========
21
22 Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC maps HW
23 resources from the network, crypto and other functional blocks into
24 PCI-compatible physical and virtual functions. Each functional block
25 again has multiple local functions (LFs) for provisioning to PCI devices.
26 RVU supports multiple PCIe SRIOV physical functions (PFs) and virtual
27 functions (VFs). PF0 is called the administrative / admin function (AF)
28 and has privileges to provision RVU functional block's LFs to each of the
29 PF/VF.
30
31 RVU managed networking functional blocks
32 - Network pool or buffer allocator (NPA)
33 - Network interface controller (NIX)
34 - Network parser CAM (NPC)
35 - Schedule/Synchronize/Order unit (SSO)
36 - Loopback interface (LBK)
37
38 RVU managed non-networking functional blocks
39 - Crypto accelerator (CPT)
40 - Scheduled timers unit (TIM)
41 - Schedule/Synchronize/Order unit (SSO)
42 Used for both networking and non networking usecases
43
44 Resource provisioning examples
45 - A PF/VF with NIX-LF & NPA-LF resources works as a pure network device
46 - A PF/VF with CPT-LF resource works as a pure crypto offload device.
47
48 RVU functional blocks are highly configurable as per software requirements.
49
50 Firmware setups following stuff before kernel boots
51 - Enables required number of RVU PFs based on number of physical links.
52 - Number of VFs per PF are either static or configurable at compile time.
53 Based on config, firmware assigns VFs to each of the PFs.
54 - Also assigns MSIX vectors to each of PF and VFs.
55 - These are not changed after kernel boot.
56
57 Drivers
58 =======
59
60 Linux kernel will have multiple drivers registering to different PF and VFs
61 of RVU. Wrt networking there will be 3 flavours of drivers.
62
63 Admin Function driver
64 ---------------------
65
66 As mentioned above RVU PF0 is called the admin function (AF), this driver
67 supports resource provisioning and configuration of functional blocks.
68 Doesn't handle any I/O. It sets up few basic stuff but most of the
69 functionality is achieved via configuration requests from PFs and VFs.
70
71 PF/VFs communicates with AF via a shared memory region (mailbox). Upon
72 receiving requests AF does resource provisioning and other HW configuration.
73 AF is always attached to host kernel, but PFs and their VFs may be used by host
74 kernel itself, or attached to VMs or to userspace applications like
75 DPDK etc. So AF has to handle provisioning/configuration requests sent
76 by any device from any domain.
77
78 AF driver also interacts with underlying firmware to
79 - Manage physical ethernet links ie CGX LMACs.
80 - Retrieve information like speed, duplex, autoneg etc
81 - Retrieve PHY EEPROM and stats.
82 - Configure FEC, PAM modes
83 - etc
84
85 From pure networking side AF driver supports following functionality.
86 - Map a physical link to a RVU PF to which a netdev is registered.
87 - Attach NIX and NPA block LFs to RVU PF/VF which provide buffer pools, RQs, SQs
88 for regular networking functionality.
89 - Flow control (pause frames) enable/disable/config.
90 - HW PTP timestamping related config.
91 - NPC parser profile config, basically how to parse pkt and what info to extract.
92 - NPC extract profile config, what to extract from the pkt to match data in MCAM entries.
93 - Manage NPC MCAM entries, upon request can frame and install requested packet forwarding rules.
94 - Defines receive side scaling (RSS) algorithms.
95 - Defines segmentation offload algorithms (eg TSO)
96 - VLAN stripping, capture and insertion config.
97 - SSO and TIM blocks config which provide packet scheduling support.
98 - Debugfs support, to check current resource provising, current status of
99 NPA pools, NIX RQ, SQ and CQs, various stats etc which helps in debugging issues.
100 - And many more.
101
102 Physical Function driver
103 ------------------------
104
105 This RVU PF handles IO, is mapped to a physical ethernet link and this
106 driver registers a netdev. This supports SR-IOV. As said above this driver
107 communicates with AF with a mailbox. To retrieve information from physical
108 links this driver talks to AF and AF gets that info from firmware and responds
109 back ie cannot talk to firmware directly.
110
111 Supports ethtool for configuring links, RSS, queue count, queue size,
112 flow control, ntuple filters, dump PHY EEPROM, config FEC etc.
113
114 Virtual Function driver
115 -----------------------
116
117 There are two types VFs, VFs that share the physical link with their parent
118 SR-IOV PF and the VFs which work in pairs using internal HW loopback channels (LBK).
119
120 Type1:
121 - These VFs and their parent PF share a physical link and used for outside communication.
122 - VFs cannot communicate with AF directly, they send mbox message to PF and PF
123 forwards that to AF. AF after processing, responds back to PF and PF forwards
124 the reply to VF.
125 - From functionality point of view there is no difference between PF and VF as same type
126 HW resources are attached to both. But user would be able to configure few stuff only
127 from PF as PF is treated as owner/admin of the link.
128
129 Type2:
130 - RVU PF0 ie admin function creates these VFs and maps them to loopback block's channels.
131 - A set of two VFs (VF0 & VF1, VF2 & VF3 .. so on) works as a pair ie pkts sent out of
132 VF0 will be received by VF1 and vice versa.
133 - These VFs can be used by applications or virtual machines to communicate between them
134 without sending traffic outside. There is no switch present in HW, hence the support
135 for loopback VFs.
136 - These communicate directly with AF (PF0) via mbox.
137
138 Except for the IO channels or links used for packet reception and transmission there is
139 no other difference between these VF types. AF driver takes care of IO channel mapping,
140 hence same VF driver works for both types of devices.
141
142 Basic packet flow
143 =================
144
145 Ingress
146 -------
147
148 1. CGX LMAC receives packet.
149 2. Forwards the packet to the NIX block.
150 3. Then submitted to NPC block for parsing and then MCAM lookup to get the destination RVU device.
151 4. NIX LF attached to the destination RVU device allocates a buffer from RQ mapped buffer pool of NPA block LF.
152 5. RQ may be selected by RSS or by configuring MCAM rule with a RQ number.
153 6. Packet is DMA'ed and driver is notified.
154
155 Egress
156 ------
157
158 1. Driver prepares a send descriptor and submits to SQ for transmission.
159 2. The SQ is already configured (by AF) to transmit on a specific link/channel.
160 3. The SQ descriptor ring is maintained in buffers allocated from SQ mapped pool of NPA block LF.
161 4. NIX block transmits the pkt on the designated channel.
162 5. NPC MCAM entries can be installed to divert pkt onto a different channel.
163
164 Devlink health reporters
165 ========================
166
167 NPA Reporters
168 -------------
169 The NPA reporters are responsible for reporting and recovering the following group of errors:
170
171 1. GENERAL events
172
173 - Error due to operation of unmapped PF.
174 - Error due to disabled alloc/free for other HW blocks (NIX, SSO, TIM, DPI and AURA).
175
176 2. ERROR events
177
178 - Fault due to NPA_AQ_INST_S read or NPA_AQ_RES_S write.
179 - AQ Doorbell Error.
180
181 3. RAS events
182
183 - RAS Error Reporting for NPA_AQ_INST_S/NPA_AQ_RES_S.
184
185 4. RVU events
186
187 - Error due to unmapped slot.
188
189 Sample Output::
190
191 ~# devlink health
192 pci/0002:01:00.0:
193 reporter hw_npa_intr
194 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 true
195 reporter hw_npa_gen
196 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 true
197 reporter hw_npa_err
198 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 true
199 reporter hw_npa_ras
200 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 true
201
202 Each reporter dumps the
203
204 - Error Type
205 - Error Register value
206 - Reason in words
207
208 For example::
209
210 ~# devlink health dump show pci/0002:01:00.0 reporter hw_npa_gen
211 NPA_AF_GENERAL:
212 NPA General Interrupt Reg : 1
213 NIX0: free disabled RX
214 ~# devlink health dump show pci/0002:01:00.0 reporter hw_npa_intr
215 NPA_AF_RVU:
216 NPA RVU Interrupt Reg : 1
217 Unmap Slot Error
218 ~# devlink health dump show pci/0002:01:00.0 reporter hw_npa_err
219 NPA_AF_ERR:
220 NPA Error Interrupt Reg : 4096
221 AQ Doorbell Error
222
223
224 NIX Reporters
225 -------------
226 The NIX reporters are responsible for reporting and recovering the following group of errors:
227
228 1. GENERAL events
229
230 - Receive mirror/multicast packet drop due to insufficient buffer.
231 - SMQ Flush operation.
232
233 2. ERROR events
234
235 - Memory Fault due to WQE read/write from multicast/mirror buffer.
236 - Receive multicast/mirror replication list error.
237 - Receive packet on an unmapped PF.
238 - Fault due to NIX_AQ_INST_S read or NIX_AQ_RES_S write.
239 - AQ Doorbell Error.
240
241 3. RAS events
242
243 - RAS Error Reporting for NIX Receive Multicast/Mirror Entry Structure.
244 - RAS Error Reporting for WQE/Packet Data read from Multicast/Mirror Buffer..
245 - RAS Error Reporting for NIX_AQ_INST_S/NIX_AQ_RES_S.
246
247 4. RVU events
248
249 - Error due to unmapped slot.
250
251 Sample Output::
252
253 ~# ./devlink health
254 pci/0002:01:00.0:
255 reporter hw_npa_intr
256 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
257 reporter hw_npa_gen
258 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
259 reporter hw_npa_err
260 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
261 reporter hw_npa_ras
262 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
263 reporter hw_nix_intr
264 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 true
265 reporter hw_nix_gen
266 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 true
267 reporter hw_nix_err
268 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 true
269 reporter hw_nix_ras
270 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 true
271
272 Each reporter dumps the
273
274 - Error Type
275 - Error Register value
276 - Reason in words
277
278 For example::
279
280 ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_intr
281 NIX_AF_RVU:
282 NIX RVU Interrupt Reg : 1
283 Unmap Slot Error
284 ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_gen
285 NIX_AF_GENERAL:
286 NIX General Interrupt Reg : 1
287 Rx multicast pkt drop
288 ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_err
289 NIX_AF_ERR:
290 NIX Error Interrupt Reg : 64
291 Rx on unmapped PF_FUNC
292
293
294 Quality of service
295 ==================
296
297
298 Hardware algorithms used in scheduling
299 --------------------------------------
300
301 octeontx2 silicon and CN10K transmit interface consists of five transmit levels
302 starting from SMQ/MDQ, TL4 to TL1. Each packet will traverse MDQ, TL4 to TL1
303 levels. Each level contains an array of queues to support scheduling and shaping.
304 The hardware uses the below algorithms depending on the priority of scheduler queues.
305 once the usercreates tc classes with different priorities, the driver configures
306 schedulers allocated to the class with specified priority along with rate-limiting
307 configuration.
308
309 1. Strict Priority
310
311 - Once packets are submitted to MDQ, hardware picks all active MDQs having different priority
312 using strict priority.
313
314 2. Round Robin
315
316 - Active MDQs having the same priority level are chosen using round robin.
317
318
319 Setup HTB offload
320 -----------------
321
322 1. Enable HW TC offload on the interface::
323
324 # ethtool -K <interface> hw-tc-offload on
325
326 2. Crate htb root::
327
328 # tc qdisc add dev <interface> clsact
329 # tc qdisc replace dev <interface> root handle 1: htb offload
330
331 3. Create tc classes with different priorities::
332
333 # tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 1
334
335 # tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 7
336
337 4. Create tc classes with same priorities and different quantum::
338
339 # tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 2 quantum 409600
340
341 # tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 2 quantum 188416
342
343 # tc class add dev <interface> parent 1: classid 1:3 htb rate 10Gbit prio 2 quantum 32768
344
345
346 RVU Representors
347 ================
348
349 RVU representor driver adds support for creation of representor devices for
350 RVU PFs' VFs in the system. Representor devices are created when user enables
351 the switchdev mode.
352 Switchdev mode can be enabled either before or after setting up SRIOV numVFs.
353 All representor devices share a single NIXLF but each has a dedicated Rx/Tx
354 queues. RVU PF representor driver registers a separate netdev for each
355 Rx/Tx queue pair.
356
357 Current HW does not support built-in switch which can do L2 learning and
358 forwarding packets between representee and representor. Hence, packet path
359 between representee and it's representor is achieved by setting up appropriate
360 NPC MCAM filters.
361 Transmit packets matching these filters will be loopbacked through hardware
362 loopback channel/interface (i.e, instead of sending them out of MAC interface).
363 Which will again match the installed filters and will be forwarded.
364 This way representee => representor and representor => representee packet
365 path is achieved. These rules get installed when representors are created
366 and gets active/deactivate based on the representor/representee interface state.
367
368 Usage example:
369
370 - Change device to switchdev mode::
371
372 # devlink dev eswitch set pci/0002:1c:00.0 mode switchdev
373
374 - List of representor devices on the system::
375
376 # ip link show
377 Rpf1vf0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether f6:43:83:ee:26:21 brd ff:ff:ff:ff:ff:ff
378 Rpf1vf1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 12:b2:54:0e:24:54 brd ff:ff:ff:ff:ff:ff
379 Rpf1vf2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 4a:12:c4:4c:32:62 brd ff:ff:ff:ff:ff:ff
380 Rpf1vf3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether ca:cb:68:0e:e2:6e brd ff:ff:ff:ff:ff:ff
381 Rpf2vf0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 06:cc:ad:b4:f0:93 brd ff:ff:ff:ff:ff:ff
382
383
384 To delete the representors devices from the system. Change the device to legacy mode.
385
386 - Change device to legacy mode::
387
388 # devlink dev eswitch set pci/0002:1c:00.0 mode legacy
389
390 RVU representors can be managed using devlink ports
391 (see :ref:`Documentation/networking/devlink/devlink-port.rst <devlink_port>`) interface.
392
393 - Show devlink ports of representors::
394
395 # devlink port
396 pci/0002:1c:00.0/0: type eth netdev Rpf1vf0 flavour physical port 0 splittable false
397 pci/0002:1c:00.0/1: type eth netdev Rpf1vf1 flavour pcivf controller 0 pfnum 1 vfnum 1 external false splittable false
398 pci/0002:1c:00.0/2: type eth netdev Rpf1vf2 flavour pcivf controller 0 pfnum 1 vfnum 2 external false splittable false
399 pci/0002:1c:00.0/3: type eth netdev Rpf1vf3 flavour pcivf controller 0 pfnum 1 vfnum 3 external false splittable false
400
401 Function attributes
402 ===================
403
404 The RVU representor support function attributes for representors.
405 Port function configuration of the representors are supported through devlink eswitch port.
406
407 MAC address setup
408 -----------------
409
410 RVU representor driver support devlink port function attr mechanism to setup MAC
411 address. (refer to Documentation/networking/devlink/devlink-port.rst)
412
413 - To setup MAC address for port 2::
414
415 # devlink port function set pci/0002:1c:00.0/2 hw_addr 5c:a1:1b:5e:43:11
416 # devlink port show pci/0002:1c:00.0/2
417 pci/0002:1c:00.0/2: type eth netdev Rpf1vf2 flavour pcivf controller 0 pfnum 1 vfnum 2 external false splittable false
418 function:
419 hw_addr 5c:a1:1b:5e:43:11
420
421
422 TC offload
423 ==========
424
425 The rvu representor driver implements support for offloading tc rules using port representors.
426
427 - Drop packets with vlan id 3::
428
429 # tc filter add dev Rpf1vf0 protocol 802.1Q parent ffff: flower vlan_id 3 vlan_ethtype ipv4 skip_sw action drop
430
431 - Redirect packets with vlan id 5 and IPv4 packets to eth1, after stripping vlan header.::
432
433 # tc filter add dev Rpf1vf0 ingress protocol 802.1Q flower vlan_id 5 vlan_ethtype ipv4 skip_sw action vlan pop action mirred ingress redirect dev eth1
434

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

RVU 개요와 resource provisioning

1-56

이 문서는 `GPL-2.0-only OR BSD-2-Clause` 이중 라이선스를 따릅니다.

Marvell OcteonTx2 RVU Kernel Driver

Copyright (c) 2020 Marvell International Ltd.

목차

  • 개요
  • Driver
  • 기본 packet flow
  • Devlink health reporter
  • Quality of service
  • RVU representor

개요

Marvell OcteonTX2 SoC의 Resource Virtualization Unit(RVU)은 network, crypto와 다른 functional block의 hardware resource를 PCI-compatible Physical Function(PF)과 Virtual Function(VF)에 mapping합니다. 각 functional block에는 PCI device에 provision할 수 있는 여러 Local Function(LF)이 있습니다.

RVU는 여러 PCIe SR-IOV PF와 VF를 지원합니다. PF0는 administrative function 또는 Admin Function(AF)이라 부르며 각 PF/VF에 RVU functional block의 LF를 provision할 권한이 있습니다.

RVU가 관리하는 networking functional block

  • Network Pool or buffer Allocator(NPA)
  • Network Interface Controller(NIX)
  • Network Parser CAM(NPC)
  • Schedule/Synchronize/Order unit(SSO)
  • Loopback interface(LBK)

RVU가 관리하는 non-networking functional block

  • Crypto accelerator(CPT)
  • Scheduled Timer unit(TIM)
  • networking과 non-networking 모두에 쓰이는 SSO

Resource provisioning 예

  • NIX-LF와 NPA-LF resource를 받은 PF/VF는 순수 network device로 동작합니다.
  • CPT-LF resource를 받은 PF/VF는 순수 crypto offload device로 동작합니다.

RVU functional block은 software requirement에 맞춰 매우 유연하게 구성할 수 있습니다.

kernel boot 전에 firmware가 설정하는 항목

  • physical link 수에 따라 필요한 RVU PF 수를 활성화합니다.
  • PF별 VF 수는 static이거나 compile time에 구성할 수 있습니다. firmware는 이 configuration에 따라 각 PF에 VF를 할당합니다.
  • 각 PF와 VF에 MSI-X vector를 할당합니다.
  • 이 설정은 kernel boot 뒤에는 바뀌지 않습니다.
.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

====================================
Marvell OcteonTx2 RVU Kernel Drivers
====================================

Copyright (c) 2020 Marvell International Ltd.

Contents
========

- `Overview`_
- `Drivers`_
- `Basic packet flow`_
- `Devlink health reporters`_
- `Quality of service`_
- `RVU representors`_

Overview
========

Resource virtualization unit (RVU) on Marvell's OcteonTX2 SOC maps HW
resources from the network, crypto and other functional blocks into
PCI-compatible physical and virtual functions. Each functional block
again has multiple local functions (LFs) for provisioning to PCI devices.
RVU supports multiple PCIe SRIOV physical functions (PFs) and virtual
functions (VFs). PF0 is called the administrative / admin function (AF)
and has privileges to provision RVU functional block's LFs to each of the
PF/VF.

RVU managed networking functional blocks
 - Network pool or buffer allocator (NPA)
 - Network interface controller (NIX)
 - Network parser CAM (NPC)
 - Schedule/Synchronize/Order unit (SSO)
 - Loopback interface (LBK)

RVU managed non-networking functional blocks
 - Crypto accelerator (CPT)
 - Scheduled timers unit (TIM)
 - Schedule/Synchronize/Order unit (SSO)
   Used for both networking and non networking usecases

Resource provisioning examples
 - A PF/VF with NIX-LF & NPA-LF resources works as a pure network device
 - A PF/VF with CPT-LF resource works as a pure crypto offload device.

RVU functional blocks are highly configurable as per software requirements.

Firmware setups following stuff before kernel boots
 - Enables required number of RVU PFs based on number of physical links.
 - Number of VFs per PF are either static or configurable at compile time.
   Based on config, firmware assigns VFs to each of the PFs.
 - Also assigns MSIX vectors to each of PF and VFs.
 - These are not changed after kernel boot.

Admin Function driver

57-101

Driver

Linux kernel에는 RVU의 서로 다른 PF와 VF에 등록되는 여러 driver가 있습니다. networking 관점에서는 세 종류로 나뉩니다.

Admin Function driver

RVU PF0인 AF driver는 resource provisioning과 functional block configuration을 담당하며 I/O는 직접 처리하지 않습니다. 기본 항목 일부를 설정하지만 대부분의 기능은 PF와 VF가 보내는 configuration request로 수행합니다.

PF/VF는 shared memory region인 mailbox를 통해 AF와 통신합니다. AF는 request를 받으면 resource를 provision하고 다른 hardware configuration을 수행합니다.

AF는 항상 host kernel에 연결됩니다. 반면 PF와 그 VF는 host kernel이 직접 사용하거나 VM 또는 DPDK 같은 user-space application에 연결할 수 있습니다. 따라서 AF는 어느 domain의 device가 보낸 provisioning·configuration request도 처리해야 합니다.

AF driver가 firmware와 상호작용해 수행하는 작업

  • CGX LMAC 같은 physical Ethernet link를 관리합니다.
  • speed, duplex, auto-negotiation 정보를 가져옵니다.
  • PHY EEPROM과 통계를 가져옵니다.
  • FEC와 PAM mode를 구성합니다.

순수 networking 관점에서 AF driver가 지원하는 기능

  • netdev가 등록될 RVU PF에 physical link를 mapping합니다.
  • 일반 networking에 필요한 buffer pool, Receive Queue(RQ), Send Queue(SQ)를 제공하도록 NIX·NPA block LF를 RVU PF/VF에 연결합니다.
  • Flow Control(pause frame)을 켜고 끄거나 구성합니다.
  • hardware PTP timestamping 관련 항목을 구성합니다.
  • packet parsing 방법과 추출 정보를 정하는 NPC parser profile을 구성합니다.
  • MCAM entry와 비교할 packet field를 정하는 NPC extract profile을 구성합니다.
  • 요청에 따라 packet forwarding rule을 만들고 설치하는 NPC MCAM entry를 관리합니다.
  • Receive Side Scaling(RSS) algorithm을 정의합니다.
  • TSO 같은 segmentation offload algorithm을 정의합니다.
  • VLAN stripping, capture와 insertion을 구성합니다.
  • packet scheduling을 제공하는 SSO와 TIM block을 구성합니다.
  • 현재 resource provisioning, NPA pool, NIX RQ·SQ·CQ 상태와 통계를 점검할 debugfs를 지원합니다.
Drivers
=======

Linux kernel will have multiple drivers registering to different PF and VFs
of RVU. Wrt networking there will be 3 flavours of drivers.

Admin Function driver
---------------------

As mentioned above RVU PF0 is called the admin function (AF), this driver
supports resource provisioning and configuration of functional blocks.
Doesn't handle any I/O. It sets up few basic stuff but most of the
functionality is achieved via configuration requests from PFs and VFs.

PF/VFs communicates with AF via a shared memory region (mailbox). Upon
receiving requests AF does resource provisioning and other HW configuration.
AF is always attached to host kernel, but PFs and their VFs may be used by host
kernel itself, or attached to VMs or to userspace applications like
DPDK etc. So AF has to handle provisioning/configuration requests sent
by any device from any domain.

AF driver also interacts with underlying firmware to
 - Manage physical ethernet links ie CGX LMACs.
 - Retrieve information like speed, duplex, autoneg etc
 - Retrieve PHY EEPROM and stats.
 - Configure FEC, PAM modes
 - etc

From pure networking side AF driver supports following functionality.
 - Map a physical link to a RVU PF to which a netdev is registered.
 - Attach NIX and NPA block LFs to RVU PF/VF which provide buffer pools, RQs, SQs
   for regular networking functionality.
 - Flow control (pause frames) enable/disable/config.
 - HW PTP timestamping related config.
 - NPC parser profile config, basically how to parse pkt and what info to extract.
 - NPC extract profile config, what to extract from the pkt to match data in MCAM entries.
 - Manage NPC MCAM entries, upon request can frame and install requested packet forwarding rules.
 - Defines receive side scaling (RSS) algorithms.
 - Defines segmentation offload algorithms (eg TSO)
 - VLAN stripping, capture and insertion config.
 - SSO and TIM blocks config which provide packet scheduling support.
 - Debugfs support, to check current resource provising, current status of
   NPA pools, NIX RQ, SQ and CQs, various stats etc which helps in debugging issues.
 - And many more.

Physical Function과 Virtual Function driver

102-141

Physical Function driver

RVU PF는 I/O를 처리하고 physical Ethernet link에 mapping되며 driver는 netdev를 등록합니다. SR-IOV를 지원하고 mailbox로 AF와 통신합니다.

PF driver는 physical link 정보를 firmware에서 직접 가져올 수 없습니다. AF에 요청하면 AF가 firmware에서 정보를 가져와 PF에 응답합니다.

ethtool을 이용한 link, RSS, queue 수·크기, Flow Control, ntuple filter, PHY EEPROM dump와 FEC configuration을 지원합니다.

Virtual Function driver

VF에는 parent SR-IOV PF와 physical link를 공유하는 Type 1과 내부 hardware loopback channel(LBK)으로 pair를 이루는 Type 2가 있습니다.

Type 1 VF

  • parent PF와 physical link를 공유하며 외부 통신에 사용합니다.
  • AF와 직접 통신할 수 없습니다. VF가 PF에 mailbox message를 보내면 PF가 AF로 전달하고, AF의 응답도 PF를 거쳐 VF에 전달됩니다.
  • PF와 VF에 같은 type의 hardware resource가 연결되므로 기능상 차이는 없습니다. 다만 PF를 link의 owner/admin으로 취급하므로 일부 항목은 PF에서만 구성할 수 있습니다.

Type 2 VF

  • AF인 RVU PF0가 VF를 만들고 loopback block channel에 mapping합니다.
  • VF0·VF1, VF2·VF3처럼 두 VF가 pair로 동작합니다. VF0에서 내보낸 packet은 VF1이 받고 그 반대도 같습니다.
  • application이나 VM 사이에서 traffic을 외부로 내보내지 않고 통신하는 데 사용할 수 있습니다. hardware에 switch가 없기 때문에 loopback VF를 지원합니다.
  • AF(PF0)와 mailbox로 직접 통신합니다.

두 VF type은 packet 송수신에 사용하는 I/O channel 또는 link만 다르고 나머지는 같습니다. AF driver가 I/O channel mapping을 처리하므로 같은 VF driver가 두 type 모두에서 동작합니다.

Physical Function driver
------------------------

This RVU PF handles IO, is mapped to a physical ethernet link and this
driver registers a netdev. This supports SR-IOV. As said above this driver
communicates with AF with a mailbox. To retrieve information from physical
links this driver talks to AF and AF gets that info from firmware and responds
back ie cannot talk to firmware directly.

Supports ethtool for configuring links, RSS, queue count, queue size,
flow control, ntuple filters, dump PHY EEPROM, config FEC etc.

Virtual Function driver
-----------------------

There are two types VFs, VFs that share the physical link with their parent
SR-IOV PF and the VFs which work in pairs using internal HW loopback channels (LBK).

Type1:
 - These VFs and their parent PF share a physical link and used for outside communication.
 - VFs cannot communicate with AF directly, they send mbox message to PF and PF
   forwards that to AF. AF after processing, responds back to PF and PF forwards
   the reply to VF.
 - From functionality point of view there is no difference between PF and VF as same type
   HW resources are attached to both. But user would be able to configure few stuff only
   from PF as PF is treated as owner/admin of the link.

Type2:
 - RVU PF0 ie admin function creates these VFs and maps them to loopback block's channels.
 - A set of two VFs (VF0 & VF1, VF2 & VF3 .. so on) works as a pair ie pkts sent out of
   VF0 will be received by VF1 and vice versa.
 - These VFs can be used by applications or virtual machines to communicate between them
   without sending traffic outside. There is no switch present in HW, hence the support
   for loopback VFs.
 - These communicate directly with AF (PF0) via mbox.

Except for the IO channels or links used for packet reception and transmission there is
no other difference between these VF types. AF driver takes care of IO channel mapping,
hence same VF driver works for both types of devices.

Ingress와 egress packet flow

142-163

기본 packet flow

Ingress

  • 1. CGX LMAC가 packet을 수신합니다.
  • 2. packet을 NIX block으로 전달합니다.
  • 3. NPC block이 packet을 parse하고 MCAM lookup으로 destination RVU device를 찾습니다.
  • 4. destination RVU device에 연결된 NIX LF가 NPA block LF의 RQ-mapped buffer pool에서 buffer를 allocate합니다.
  • 5. RSS 또는 RQ number를 지정한 MCAM rule이 RQ를 선택할 수 있습니다.
  • 6. packet을 DMA하고 driver에 알립니다.

Egress

  • 1. driver가 send descriptor를 준비해 transmission용 SQ에 submit합니다.
  • 2. SQ는 AF가 특정 link 또는 channel로 전송하도록 미리 구성해 둡니다.
  • 3. SQ descriptor ring은 NPA block LF의 SQ-mapped pool에서 allocate한 buffer에 유지됩니다.
  • 4. NIX block이 지정 channel로 packet을 전송합니다.
  • 5. NPC MCAM entry를 설치하면 packet을 다른 channel로 돌릴 수 있습니다.
Basic packet flow
=================

Ingress
-------

1. CGX LMAC receives packet.
2. Forwards the packet to the NIX block.
3. Then submitted to NPC block for parsing and then MCAM lookup to get the destination RVU device.
4. NIX LF attached to the destination RVU device allocates a buffer from RQ mapped buffer pool of NPA block LF.
5. RQ may be selected by RSS or by configuring MCAM rule with a RQ number.
6. Packet is DMA'ed and driver is notified.

Egress
------

1. Driver prepares a send descriptor and submits to SQ for transmission.
2. The SQ is already configured (by AF) to transmit on a specific link/channel.
3. The SQ descriptor ring is maintained in buffers allocated from SQ mapped pool of NPA block LF.
4. NIX block transmits the pkt on the designated channel.
5. NPC MCAM entries can be installed to divert pkt onto a different channel.

NPA devlink health reporter

164-223

Devlink health reporter

NPA reporter

NPA reporter는 다음 error group을 보고하고 recovery합니다.

NPA health error group
Group보고 대상
GENERALmapping되지 않은 PF operation, NIX·SSO·TIM·DPI·AURA의 alloc/free disabled
ERRORNPA_AQ_INST_S read 또는 NPA_AQ_RES_S write fault, AQ Doorbell Error
RASNPA_AQ_INST_S/NPA_AQ_RES_S의 RAS error
RVUmapping되지 않은 slot

NPA reporter가 다루는 event와 대표 원인입니다.

`devlink health` sample에는 `hw_npa_intr`, `hw_npa_gen`, `hw_npa_err`, `hw_npa_ras` reporter와 각 state, error·recover count, 마지막 dump 시각, auto recovery/dump 상태가 표시됩니다.

devlink health

각 reporter dump는 다음 정보를 제공합니다.

  • Error Type
  • Error Register value
  • 문장으로 된 원인

아래 command로 reporter별 dump를 확인할 수 있습니다. 예시에서는 각각 NIX0 free disabled RX, Unmap Slot Error와 AQ Doorbell Error가 보고됩니다.

devlink health dump show pci/0002:01:00.0 reporter hw_npa_gen
devlink health dump show pci/0002:01:00.0 reporter hw_npa_intr
devlink health dump show pci/0002:01:00.0 reporter hw_npa_err
Devlink health reporters
========================

NPA Reporters
-------------
The NPA reporters are responsible for reporting and recovering the following group of errors:

1. GENERAL events

   - Error due to operation of unmapped PF.
   - Error due to disabled alloc/free for other HW blocks (NIX, SSO, TIM, DPI and AURA).

2. ERROR events

   - Fault due to NPA_AQ_INST_S read or NPA_AQ_RES_S write.
   - AQ Doorbell Error.

3. RAS events

   - RAS Error Reporting for NPA_AQ_INST_S/NPA_AQ_RES_S.

4. RVU events

   - Error due to unmapped slot.

Sample Output::

        ~# devlink health
        pci/0002:01:00.0:
          reporter hw_npa_intr
              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 true
          reporter hw_npa_gen
              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 true
          reporter hw_npa_err
              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 true
           reporter hw_npa_ras
              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 true

Each reporter dumps the

 - Error Type
 - Error Register value
 - Reason in words

For example::

        ~# devlink health dump show  pci/0002:01:00.0 reporter hw_npa_gen
         NPA_AF_GENERAL:
                 NPA General Interrupt Reg : 1
                 NIX0: free disabled RX
        ~# devlink health dump show  pci/0002:01:00.0 reporter hw_npa_intr
         NPA_AF_RVU:
                 NPA RVU Interrupt Reg : 1
                 Unmap Slot Error
        ~# devlink health dump show  pci/0002:01:00.0 reporter hw_npa_err
         NPA_AF_ERR:
                NPA Error Interrupt Reg : 4096
                AQ Doorbell Error

NIX devlink health reporter

224-293

NIX reporter

NIX reporter는 다음 error group을 보고하고 recovery합니다.

NIX health error group
Group보고 대상
GENERALbuffer 부족으로 인한 receive mirror/multicast drop, SMQ flush
ERRORmulticast/mirror buffer WQE read/write memory fault, replication list error, unmapped PF 수신, NIX AQ fault, AQ Doorbell Error
RASNIX multicast/mirror entry, WQE/packet data, NIX_AQ_INST_S/NIX_AQ_RES_S의 RAS error
RVUmapping되지 않은 slot

NIX reporter가 다루는 event와 대표 원인입니다.

`devlink health` sample에는 NPA reporter와 함께 `hw_nix_intr`, `hw_nix_gen`, `hw_nix_err`, `hw_nix_ras` reporter의 상태와 누적 error·recovery 수가 표시됩니다.

각 reporter dump는 다음 정보를 제공합니다.

  • Error Type
  • Error Register value
  • 문장으로 된 원인

아래 command로 NIX reporter dump를 확인합니다. 예시는 Unmap Slot Error, Rx multicast packet drop과 unmapped `PF_FUNC`에서의 Rx를 보여 줍니다.

devlink health dump show pci/0002:01:00.0 reporter hw_nix_intr
devlink health dump show pci/0002:01:00.0 reporter hw_nix_gen
devlink health dump show pci/0002:01:00.0 reporter hw_nix_err
NIX Reporters
-------------
The NIX reporters are responsible for reporting and recovering the following group of errors:

1. GENERAL events

   - Receive mirror/multicast packet drop due to insufficient buffer.
   - SMQ Flush operation.

2. ERROR events

   - Memory Fault due to WQE read/write from multicast/mirror buffer.
   - Receive multicast/mirror replication list error.
   - Receive packet on an unmapped PF.
   - Fault due to NIX_AQ_INST_S read or NIX_AQ_RES_S write.
   - AQ Doorbell Error.

3. RAS events

   - RAS Error Reporting for NIX Receive Multicast/Mirror Entry Structure.
   - RAS Error Reporting for WQE/Packet Data read from Multicast/Mirror Buffer..
   - RAS Error Reporting for NIX_AQ_INST_S/NIX_AQ_RES_S.

4. RVU events

   - Error due to unmapped slot.

Sample Output::

        ~# ./devlink health
        pci/0002:01:00.0:
          reporter hw_npa_intr
            state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
          reporter hw_npa_gen
            state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
          reporter hw_npa_err
            state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
          reporter hw_npa_ras
            state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump true
          reporter hw_nix_intr
            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 true
          reporter hw_nix_gen
            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 true
          reporter hw_nix_err
            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 true
          reporter hw_nix_ras
            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 true

Each reporter dumps the

 - Error Type
 - Error Register value
 - Reason in words

For example::

        ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_intr
         NIX_AF_RVU:
                NIX RVU Interrupt Reg : 1
                Unmap Slot Error
        ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_gen
         NIX_AF_GENERAL:
                NIX General Interrupt Reg : 1
                Rx multicast pkt drop
        ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_err
         NIX_AF_ERR:
                NIX Error Interrupt Reg : 64
                Rx on unmapped PF_FUNC

QoS scheduler와 HTB offload

294-345

Quality of Service

Scheduling에 사용하는 hardware algorithm

OcteonTX2 silicon과 CN10K transmit interface에는 SMQ/MDQ에서 시작해 TL4, TL3, TL2, TL1로 이어지는 다섯 transmit level이 있습니다. 각 packet은 MDQ에서 TL4를 거쳐 TL1까지 통과합니다. 각 level에는 scheduling과 shaping을 위한 queue array가 있습니다.

hardware는 scheduler queue priority에 따라 algorithm을 선택합니다. 사용자가 priority가 다른 tc class를 만들면 driver는 지정 priority와 rate limit configuration을 class에 할당된 scheduler에 구성합니다.

1. Strict Priority

packet이 MDQ에 submit되면 hardware는 priority가 서로 다른 active MDQ를 strict priority 방식으로 선택합니다.

2. Round Robin

priority level이 같은 active MDQ는 round-robin 방식으로 선택합니다.

HTB offload 설정

1. interface에서 hardware TC offload를 켭니다.

ethtool -K <interface> hw-tc-offload on

2. clsact와 HTB root를 만듭니다.

tc qdisc add dev <interface> clsact
tc qdisc replace dev <interface> root handle 1: htb offload

3. priority가 서로 다른 tc class를 만듭니다.

tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 1
tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 7

4. priority는 같고 quantum이 서로 다른 tc class를 만듭니다.

tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 2 quantum 409600
tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 2 quantum 188416
tc class add dev <interface> parent 1: classid 1:3 htb rate 10Gbit prio 2 quantum 32768
Quality of service
==================


Hardware algorithms used in scheduling
--------------------------------------

octeontx2 silicon and CN10K transmit interface consists of five transmit levels
starting from SMQ/MDQ, TL4 to TL1. Each packet will traverse MDQ, TL4 to TL1
levels. Each level contains an array of queues to support scheduling and shaping.
The hardware uses the below algorithms depending on the priority of scheduler queues.
once the usercreates tc classes with different priorities, the driver configures
schedulers allocated to the class with specified priority along with rate-limiting
configuration.

1. Strict Priority

      -  Once packets are submitted to MDQ, hardware picks all active MDQs having different priority
         using strict priority.

2. Round Robin

      - Active MDQs having the same priority level are chosen using round robin.


Setup HTB offload
-----------------

1. Enable HW TC offload on the interface::

        # ethtool -K <interface> hw-tc-offload on

2. Crate htb root::

        # tc qdisc add dev <interface> clsact
        # tc qdisc replace dev <interface> root handle 1: htb offload

3. Create tc classes with different priorities::

        # tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 1

        # tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 7

4. Create tc classes with same priorities and different quantum::

        # tc class add dev <interface> parent 1: classid 1:1 htb rate 10Gbit prio 2 quantum 409600

        # tc class add dev <interface> parent 1: classid 1:2 htb rate 10Gbit prio 2 quantum 188416

        # tc class add dev <interface> parent 1: classid 1:3 htb rate 10Gbit prio 2 quantum 32768

RVU representor와 switchdev mode

346-400

RVU Representor

RVU representor driver는 system에서 RVU PF의 VF를 대표하는 representor device를 생성합니다. 사용자가 switchdev mode를 켜면 representor가 만들어지며, SR-IOV `numVFs`를 설정하기 전이나 후 모두 switchdev mode를 켤 수 있습니다.

모든 representor device는 NIX LF 하나를 공유하지만 각각 전용 Rx/Tx queue를 가집니다. RVU PF representor driver는 Rx/Tx queue pair마다 별도 netdev를 등록합니다.

현재 hardware에는 representee와 representor 사이에서 L2 learning과 packet forwarding을 수행하는 built-in switch가 없습니다. 따라서 적절한 NPC MCAM filter를 설정해 두 방향 packet path를 만듭니다.

filter와 일치하는 transmit packet은 MAC interface로 나가지 않고 hardware loopback channel/interface로 되돌아옵니다. 다시 설치된 filter와 일치한 뒤 forwarding되어 `representee => representor`와 `representor => representee` path를 완성합니다.

rule은 representor 생성 때 설치되며 representor와 representee interface state에 따라 활성화되거나 비활성화됩니다.

사용 예

device를 switchdev mode로 바꿉니다.

devlink dev eswitch set pci/0002:1c:00.0 mode switchdev

`ip link show`에는 `Rpf1vf0`, `Rpf1vf1`, `Rpf1vf2`, `Rpf1vf3`, `Rpf2vf0` 같은 representor netdev가 표시됩니다.

ip link show

system에서 representor device를 삭제하려면 device를 legacy mode로 되돌립니다.

devlink dev eswitch set pci/0002:1c:00.0 mode legacy

RVU representor는 devlink port interface로 관리할 수 있습니다. 자세한 내용은 `Documentation/networking/devlink/devlink-port.rst`를 참고하십시오.

representor의 devlink port를 표시합니다.

devlink port

출력에는 physical port와 `flavour pcivf` port별 controller, `pfnum`, `vfnum`과 연결 netdev가 표시됩니다.

RVU Representors
================

RVU representor driver adds support for creation of representor devices for
RVU PFs' VFs in the system. Representor devices are created when user enables
the switchdev mode.
Switchdev mode can be enabled either before or after setting up SRIOV numVFs.
All representor devices share a single NIXLF but each has a dedicated Rx/Tx
queues. RVU PF representor driver registers a separate netdev for each
Rx/Tx queue pair.

Current HW does not support built-in switch which can do L2 learning and
forwarding packets between representee and representor. Hence, packet path
between representee and it's representor is achieved by setting up appropriate
NPC MCAM filters.
Transmit packets matching these filters will be loopbacked through hardware
loopback channel/interface (i.e, instead of sending them out of MAC interface).
Which will again match the installed filters and will be forwarded.
This way representee => representor and representor => representee packet
path is achieved. These rules get installed when representors are created
and gets active/deactivate based on the representor/representee interface state.

Usage example:

 - Change device to switchdev mode::

        # devlink dev eswitch set pci/0002:1c:00.0 mode switchdev

 - List of representor devices on the system::

        # ip link show
        Rpf1vf0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether f6:43:83:ee:26:21 brd ff:ff:ff:ff:ff:ff
        Rpf1vf1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 12:b2:54:0e:24:54 brd ff:ff:ff:ff:ff:ff
        Rpf1vf2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 4a:12:c4:4c:32:62 brd ff:ff:ff:ff:ff:ff
        Rpf1vf3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether ca:cb:68:0e:e2:6e brd ff:ff:ff:ff:ff:ff
        Rpf2vf0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 06:cc:ad:b4:f0:93 brd ff:ff:ff:ff:ff:ff


To delete the representors devices from the system. Change the device to legacy mode.

 - Change device to legacy mode::

        # devlink dev eswitch set pci/0002:1c:00.0 mode legacy

RVU representors can be managed using devlink ports
(see :ref:`Documentation/networking/devlink/devlink-port.rst <devlink_port>`) interface.

 - Show devlink ports of representors::

        # devlink port
        pci/0002:1c:00.0/0: type eth netdev Rpf1vf0 flavour physical port 0 splittable false
        pci/0002:1c:00.0/1: type eth netdev Rpf1vf1 flavour pcivf controller 0 pfnum 1 vfnum 1 external false splittable false
        pci/0002:1c:00.0/2: type eth netdev Rpf1vf2 flavour pcivf controller 0 pfnum 1 vfnum 2 external false splittable false
        pci/0002:1c:00.0/3: type eth netdev Rpf1vf3 flavour pcivf controller 0 pfnum 1 vfnum 3 external false splittable false

Representor function attribute와 MAC address

401-421

Function attribute

RVU representor는 representor용 function attribute를 지원합니다. representor의 port function configuration은 devlink eswitch port를 통해 수행합니다.

MAC address 설정

RVU representor driver는 devlink port function attribute mechanism으로 MAC address를 설정할 수 있습니다. `Documentation/networking/devlink/devlink-port.rst`도 참고하십시오.

port 2에 MAC address를 설정하고 결과를 확인합니다.

devlink port function set pci/0002:1c:00.0/2 hw_addr 5c:a1:1b:5e:43:11
devlink port show pci/0002:1c:00.0/2

출력의 `function` 아래에는 설정한 `hw_addr 5c:a1:1b:5e:43:11`이 표시됩니다.

Function attributes
===================

The RVU representor support function attributes for representors.
Port function configuration of the representors are supported through devlink eswitch port.

MAC address setup
-----------------

RVU representor driver support devlink port function attr mechanism to setup MAC
address. (refer to Documentation/networking/devlink/devlink-port.rst)

 - To setup MAC address for port 2::

        # devlink port function set pci/0002:1c:00.0/2 hw_addr 5c:a1:1b:5e:43:11
        # devlink port show pci/0002:1c:00.0/2
        pci/0002:1c:00.0/2: type eth netdev Rpf1vf2 flavour pcivf controller 0 pfnum 1 vfnum 2 external false splittable false
        function:
                hw_addr 5c:a1:1b:5e:43:11

Representor TC offload

422-433

TC offload

RVU representor driver는 port representor를 이용해 tc rule을 hardware로 offload하는 기능을 구현합니다.

VLAN ID 3인 packet을 drop합니다.

tc filter add dev Rpf1vf0 protocol 802.1Q parent ffff: flower vlan_id 3 vlan_ethtype ipv4 skip_sw action drop

VLAN ID 5인 IPv4 packet에서 VLAN header를 제거한 뒤 `eth1`로 redirect합니다.

tc filter add dev Rpf1vf0 ingress protocol 802.1Q flower vlan_id 5 vlan_ethtype ipv4 skip_sw action vlan pop action mirred ingress redirect dev eth1
TC offload
==========

The rvu representor driver implements support for offloading tc rules using port representors.

 - Drop packets with vlan id 3::

        # tc filter add dev Rpf1vf0 protocol 802.1Q parent ffff: flower vlan_id 3 vlan_ethtype ipv4 skip_sw action drop

 - Redirect packets with vlan id 5 and IPv4 packets to eth1, after stripping vlan header.::

        # tc filter add dev Rpf1vf0 ingress protocol 802.1Q flower vlan_id 5 vlan_ethtype ipv4 skip_sw action vlan pop action mirred ingress redirect dev eth1