xref: /dpdk/doc/guides/howto/vfd.rst (revision 79238624c2b19bd71a20839ebf304e1eeb8dee9c)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2017 Intel Corporation.
3
4VF daemon (VFd)
5===============
6
7VFd (the VF daemon) is a mechanism which can be used to configure features on
8a VF (SR-IOV Virtual Function) without direct access to the PF (SR-IOV
9Physical Function). VFd is an *EXPERIMENTAL* feature which can only be used in
10the scenario of DPDK PF with a DPDK VF. If the PF port is driven by the Linux
11kernel driver then the VFd feature will not work. Currently VFd is only
12supported by the ixgbe and i40e drivers.
13
14In general VF features cannot be configured directly by an end user
15application since they are under the control of the PF. The normal approach to
16configuring a feature on a VF is that an application would call the APIs
17provided by the VF driver. If the required feature cannot be configured by the
18VF directly (the most common case) the VF sends a message to the PF through
19the mailbox on ixgbe and i40e. This means that the availability of the feature
20depends on whether the appropriate mailbox messages are defined.
21
22DPDK leverages the mailbox interface defined by the Linux kernel driver so
23that compatibility with the kernel driver can be guaranteed. The downside of
24this approach is that the availability of messages supported by the kernel
25become a limitation when the user wants to configure features on the VF.
26
27VFd is a new method of controlling the features on a VF. The VF driver doesn't
28talk directly to the PF driver when configuring a feature on the VF. When a VF
29application (i.e., an application using the VF ports) wants to enable a VF
30feature, it can send a message to the PF application (i.e., the application
31using the PF port, which can be the same as the VF application). The PF
32application will configure the feature for the VF. Obviously, the PF
33application can also configure the VF features without a request from the VF
34application.
35
36.. _VF_daemon_overview:
37
38.. figure:: img/vf_daemon_overview.*
39
40   VF daemon (VFd) Overview
41
42Compared with the traditional approach the VFd moves the negotiation between
43VF and PF from the driver level to application level. So the application
44should define how the negotiation between the VF and PF works, or even if the
45control should be limited to the PF.
46
47It is the application's responsibility to use VFd. Consider for example a KVM
48migration, the VF application may transfer from one VM to another. It is
49recommended in this case that the PF control the VF features without
50participation from the VF. Then the VF application has no capability to
51configure the features. So the user doesn't need to define the interface
52between the VF application and the PF application. The service provider should
53take the control of all the features.
54
55The following sections describe the VFd functionality.
56
57.. Note::
58
59   Although VFd is supported by both ixgbe and i40e, please be aware that
60   since the hardware capability is different, the functions supported by
61   ixgbe and i40e are not the same.
62
63
64Preparing
65---------
66
67VFd only can be used in the scenario of DPDK PF + DPDK VF. Users should bind
68the PF port to ``igb_uio``, then create the VFs based on the DPDK PF host.
69
70The typical procedure to achieve this is as follows:
71
72#. Boot the system without iommu, or with ``iommu=pt``.
73
74#. Bind the PF port to ``igb_uio``, for example::
75
76      dpdk-devbind.py -b igb_uio 01:00.0
77
78#. Create a Virtual Function::
79
80      echo 1 > /sys/bus/pci/devices/0000:01:00.0/max_vfs
81
82#. Start a VM with the new VF port bypassed to it.
83
84#. Run a DPDK application on the PF in the host::
85
86      dpdk-testpmd -l 0-7 -n 4 -- -i --txqflags=0
87
88#. Bind the VF port to ``igb_uio`` in the VM::
89
90      dpdk-devbind.py -b igb_uio 03:00.0
91
92#. Run a DPDK application on the VF in the VM::
93
94      dpdk-testpmd -l 0-7 -n 4 -- -i --txqflags=0
95
96
97Common functions of IXGBE and I40E
98----------------------------------
99
100The following sections show how to enable PF/VF functionality based on the
101above testpmd setup.
102
103
104TX loopback
105~~~~~~~~~~~
106
107Run a testpmd runtime command on the PF to set TX loopback::
108
109   set tx loopback 0 on|off
110
111This sets whether the PF port and all the VF ports that belong to it are
112allowed to send the packets to other virtual ports.
113
114Although it is a VFd function, it is the global setting for the whole
115physical port. When using this function, the PF and all the VFs TX loopback
116will be enabled/disabled.
117
118
119VF MAC address setting
120~~~~~~~~~~~~~~~~~~~~~~
121
122Run a testpmd runtime command on the PF to set the MAC address for a VF port::
123
124   set vf mac addr 0 0 A0:36:9F:7B:C3:51
125
126This testpmd runtime command will change the MAC address of the VF port to
127this new address. If any other addresses are set before, they will be
128overwritten.
129
130
131VF MAC anti-spoofing
132~~~~~~~~~~~~~~~~~~~~
133
134Run a testpmd runtime command on the PF to enable/disable the MAC
135anti-spoofing for a VF port::
136
137   set vf mac antispoof 0 0 on|off
138
139When enabling the MAC anti-spoofing, the port will not forward packets whose
140source MAC address is not the same as the port.
141
142
143VF VLAN anti-spoofing
144~~~~~~~~~~~~~~~~~~~~~
145
146Run a testpmd runtime command on the PF to enable/disable the VLAN
147anti-spoofing for a VF port::
148
149   set vf vlan antispoof 0 0 on|off
150
151When enabling the VLAN anti-spoofing, the port will not send packets whose
152VLAN ID does not belong to VLAN IDs that this port can receive.
153
154
155VF VLAN insertion
156~~~~~~~~~~~~~~~~~
157
158Run a testpmd runtime command on the PF to set the VLAN insertion for a VF
159port::
160
161   set vf vlan insert 0 0 1
162
163When using this testpmd runtime command, an assigned VLAN ID can be inserted
164to the transmitted packets by the hardware.
165
166The assigned VLAN ID can be 0. It means disabling the VLAN insertion.
167
168
169VF VLAN stripping
170~~~~~~~~~~~~~~~~~
171
172Run a testpmd runtime command on the PF to enable/disable the VLAN stripping
173for a VF port::
174
175   set vf vlan stripq 0 0 on|off
176
177This testpmd runtime command is used to enable/disable the RX VLAN stripping
178for a specific VF port.
179
180
181VF VLAN filtering
182~~~~~~~~~~~~~~~~~
183
184Run a testpmd runtime command on the PF to set the VLAN filtering for a VF
185port::
186
187   rx_vlan add 1 port 0 vf 1
188   rx_vlan rm  1 port 0 vf 1
189
190These two testpmd runtime commands can be used to add or remove the VLAN
191filter for several VF ports. When the VLAN filters are added only the packets
192that have the assigned VLAN IDs can be received. Other packets will be dropped
193by hardware.
194
195
196The IXGBE specific VFd functions
197--------------------------------
198
199The functions in this section are specific to the ixgbe driver.
200
201
202All queues drop
203~~~~~~~~~~~~~~~
204
205Run a testpmd runtime command on the PF to enable/disable the all queues
206drop::
207
208   set all queues drop on|off
209
210This is a global setting for the PF and all the VF ports of the physical port.
211
212Enabling the ``all queues drop`` feature means that when there is no available
213descriptor for the received packets they are dropped. The ``all queues drop``
214feature should be enabled in SR-IOV mode to avoid one queue blocking others.
215
216
217VF packet drop
218~~~~~~~~~~~~~~
219
220Run a testpmd runtime command on the PF to enable/disable the packet drop for
221a specific VF::
222
223   set vf split drop 0 0 on|off
224
225This is a similar function as ``all queues drop``. The difference is that this
226function is per VF setting and the previous function is a global setting.
227
228
229VF rate limit
230~~~~~~~~~~~~~
231
232Run a testpmd runtime command on the PF to all queues' rate limit for a
233specific VF::
234
235   set port 0 vf 0 rate 10 queue_mask 1
236
237This is a function to set the rate limit for all the queues in the
238``queue_mask`` bitmap. It is not used to set the summary of the rate
239limit. The rate limit of every queue will be set equally to the assigned rate
240limit.
241
242
243VF RX enabling
244~~~~~~~~~~~~~~
245
246Run a testpmd runtime command on the PF to enable/disable packet receiving for
247a specific VF::
248
249   set port 0 vf 0 rx on|off
250
251This function can be used to stop/start packet receiving on a VF.
252
253
254VF TX enabling
255~~~~~~~~~~~~~~
256
257Run a testpmd runtime command on the PF to enable/disable packet transmitting
258for a specific VF::
259
260   set port 0 vf 0 tx on|off
261
262This function can be used to stop/start packet transmitting on a VF.
263
264
265VF RX mode setting
266~~~~~~~~~~~~~~~~~~
267
268Run a testpmd runtime command on the PF to set the RX mode for a specific VF::
269
270   set port 0 vf 0 rxmode AUPE|ROPE|BAM|MPE on|off
271
272This function can be used to enable/disable some RX modes on the VF, including:
273
274* If it accept untagged packets.
275* If it accepts packets matching the MAC filters.
276* If it accept MAC broadcast packets,
277* If it enables MAC multicast promiscuous mode.
278
279
280The I40E specific VFd functions
281-------------------------------
282
283The functions in this section are specific to the i40e driver.
284
285
286VF statistics
287~~~~~~~~~~~~~
288
289This provides an API to get the a specific VF's statistic from PF.
290
291
292VF statistics resetting
293~~~~~~~~~~~~~~~~~~~~~~~
294
295This provides an API to rest the a specific VF's statistic from PF.
296
297
298VF link status change notification
299~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300
301This provide an API to let a specific VF know if the physical link status
302changed.
303
304Normally if a VF received this notification, the driver should notify the
305application to reset the VF port.
306
307
308VF MAC broadcast setting
309~~~~~~~~~~~~~~~~~~~~~~~~
310
311Run a testpmd runtime command on the PF to enable/disable MAC broadcast packet
312receiving for a specific VF::
313
314   set vf broadcast 0 0 on|off
315
316
317VF MAC multicast promiscuous mode
318~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319
320Run a testpmd runtime command on the PF to enable/disable MAC multicast
321promiscuous mode for a specific VF::
322
323   set vf allmulti 0 0 on|off
324
325
326VF MAC unicast promiscuous mode
327~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328
329Run a testpmd runtime command on the PF to enable/disable MAC unicast
330promiscuous mode for a specific VF::
331
332   set vf promisc 0 0 on|off
333
334
335VF max bandwidth
336~~~~~~~~~~~~~~~~
337
338Run a testpmd runtime command on the PF to set the TX maximum bandwidth for a
339specific VF::
340
341   set vf tx max-bandwidth 0 0 2000
342
343The maximum bandwidth is an absolute value in Mbps.
344
345
346VF TC bandwidth allocation
347~~~~~~~~~~~~~~~~~~~~~~~~~~
348
349Run a testpmd runtime command on the PF to set the TCs (traffic class) TX
350bandwidth allocation for a specific VF::
351
352   set vf tc tx min-bandwidth 0 0 (20,20,20,40)
353
354The allocated bandwidth should be set for all the TCs. The allocated bandwidth
355is a relative value as a percentage. The sum of all the bandwidth should
356be 100.
357
358
359VF TC max bandwidth
360~~~~~~~~~~~~~~~~~~~
361
362Run a testpmd runtime command on the PF to set the TCs TX maximum bandwidth
363for a specific VF::
364
365   set vf tc tx max-bandwidth 0 0 0 10000
366
367The maximum bandwidth is an absolute value in Mbps.
368
369
370TC strict priority scheduling
371~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372
373Run a testpmd runtime command on the PF to enable/disable several TCs TX
374strict priority scheduling::
375
376   set tx strict-link-priority 0 0x3
377
378The 0 in the TC bitmap means disabling the strict priority scheduling for this
379TC. To enable use a value of 1.
380