xref: /dpdk/doc/guides/prog_guide/ethdev/switch_representation.rst (revision 41dd9a6bc2d9c6e20e139ad713cc9d172572dd43)
1*41dd9a6bSDavid Young..  SPDX-License-Identifier: BSD-3-Clause
2*41dd9a6bSDavid Young    Copyright(c) 2018 6WIND S.A.
3*41dd9a6bSDavid Young
4*41dd9a6bSDavid YoungSwitch Representation within DPDK Applications
5*41dd9a6bSDavid Young==============================================
6*41dd9a6bSDavid Young
7*41dd9a6bSDavid Young.. contents:: :local:
8*41dd9a6bSDavid Young
9*41dd9a6bSDavid YoungIntroduction
10*41dd9a6bSDavid Young------------
11*41dd9a6bSDavid Young
12*41dd9a6bSDavid YoungNetwork adapters with multiple physical ports and/or SR-IOV capabilities
13*41dd9a6bSDavid Youngusually support the offload of traffic steering rules between their virtual
14*41dd9a6bSDavid Youngfunctions (VFs), sub functions (SFs), physical functions (PFs) and ports.
15*41dd9a6bSDavid Young
16*41dd9a6bSDavid YoungLike for standard Ethernet switches, this involves a combination of
17*41dd9a6bSDavid Youngautomatic MAC learning and manual configuration. For most purposes it is
18*41dd9a6bSDavid Youngmanaged by the host system and fully transparent to users and applications.
19*41dd9a6bSDavid Young
20*41dd9a6bSDavid YoungOn the other hand, applications typically found on hypervisors that process
21*41dd9a6bSDavid Younglayer 2 (L2) traffic (such as OVS) need to steer traffic themselves
22*41dd9a6bSDavid Youngaccording on their own criteria.
23*41dd9a6bSDavid Young
24*41dd9a6bSDavid YoungWithout a standard software interface to manage traffic steering rules
25*41dd9a6bSDavid Youngbetween VFs, SFs, PFs and the various physical ports of a given device,
26*41dd9a6bSDavid Youngapplications cannot take advantage of these offloads; software processing is
27*41dd9a6bSDavid Youngmandatory even for traffic which ends up re-injected into the device it
28*41dd9a6bSDavid Youngoriginates from.
29*41dd9a6bSDavid Young
30*41dd9a6bSDavid YoungThis document describes how such steering rules can be configured through
31*41dd9a6bSDavid Youngthe DPDK flow API (**rte_flow**), with emphasis on the SR-IOV use case
32*41dd9a6bSDavid Young(PF/VF steering) using a single physical port for clarity, however the same
33*41dd9a6bSDavid Younglogic applies to any number of ports without necessarily involving SR-IOV.
34*41dd9a6bSDavid Young
35*41dd9a6bSDavid YoungSub Function
36*41dd9a6bSDavid Young------------
37*41dd9a6bSDavid YoungBesides SR-IOV, Sub function is a portion of the PCI device, a SF netdev
38*41dd9a6bSDavid Younghas its own dedicated queues(txq, rxq). A SF netdev supports E-Switch
39*41dd9a6bSDavid Youngrepresentation offload similar to existing PF and VF representors.
40*41dd9a6bSDavid YoungA SF shares PCI level resources with other SFs and/or with its parent PCI
41*41dd9a6bSDavid Youngfunction.
42*41dd9a6bSDavid Young
43*41dd9a6bSDavid YoungSub function is created on-demand, coexists with VFs. Number of SFs is
44*41dd9a6bSDavid Younglimited by hardware resources.
45*41dd9a6bSDavid Young
46*41dd9a6bSDavid YoungPort Representors
47*41dd9a6bSDavid Young-----------------
48*41dd9a6bSDavid Young
49*41dd9a6bSDavid YoungIn many cases, traffic steering rules cannot be determined in advance;
50*41dd9a6bSDavid Youngapplications usually have to process a bit of traffic in software before
51*41dd9a6bSDavid Youngthinking about offloading specific flows to hardware.
52*41dd9a6bSDavid Young
53*41dd9a6bSDavid YoungApplications therefore need the ability to receive and inject traffic to
54*41dd9a6bSDavid Youngvarious device endpoints (other VFs, SFs, PFs or physical ports) before
55*41dd9a6bSDavid Youngconnecting them together. Device drivers must provide means to hook the
56*41dd9a6bSDavid Young"other end" of these endpoints and to refer them when configuring flow
57*41dd9a6bSDavid Youngrules.
58*41dd9a6bSDavid Young
59*41dd9a6bSDavid YoungThis role is left to so-called "port representors" (also known as "VF
60*41dd9a6bSDavid Youngrepresentors" in the specific context of VFs, "SF representors" in the
61*41dd9a6bSDavid Youngspecific context of SFs), which are to DPDK what the Ethernet switch
62*41dd9a6bSDavid Youngdevice driver model (**switchdev**) [1]_ is to Linux, and which can be
63*41dd9a6bSDavid Youngthought as a software "patch panel" front-end for applications.
64*41dd9a6bSDavid Young
65*41dd9a6bSDavid Young- DPDK port representors are implemented as additional virtual Ethernet
66*41dd9a6bSDavid Young  device (**ethdev**) instances, spawned on an as needed basis through
67*41dd9a6bSDavid Young  configuration parameters passed to the driver of the underlying
68*41dd9a6bSDavid Young  device using devargs.
69*41dd9a6bSDavid Young
70*41dd9a6bSDavid Young::
71*41dd9a6bSDavid Young
72*41dd9a6bSDavid Young   -a pci:dbdf,representor=vf0
73*41dd9a6bSDavid Young   -a pci:dbdf,representor=vf[0-3]
74*41dd9a6bSDavid Young   -a pci:dbdf,representor=vf[0,5-11]
75*41dd9a6bSDavid Young   -a pci:dbdf,representor=sf1
76*41dd9a6bSDavid Young   -a pci:dbdf,representor=sf[0-1023]
77*41dd9a6bSDavid Young   -a pci:dbdf,representor=sf[0,2-1023]
78*41dd9a6bSDavid Young   -a pci:dbdf,representor=[pf[0-1],pf2vf[0-2],pf3[3,5]]
79*41dd9a6bSDavid Young
80*41dd9a6bSDavid Young- As virtual devices, they may be more limited than their physical
81*41dd9a6bSDavid Young  counterparts, for instance by exposing only a subset of device
82*41dd9a6bSDavid Young  configuration callbacks and/or by not necessarily having Rx/Tx capability.
83*41dd9a6bSDavid Young
84*41dd9a6bSDavid Young- Among other things, they can be used to assign MAC addresses to the
85*41dd9a6bSDavid Young  resource they represent.
86*41dd9a6bSDavid Young
87*41dd9a6bSDavid Young- Applications can tell port representors apart from other physical of virtual
88*41dd9a6bSDavid Young  port by checking the dev_flags field within their device information
89*41dd9a6bSDavid Young  structure for the RTE_ETH_DEV_REPRESENTOR bit-field.
90*41dd9a6bSDavid Young
91*41dd9a6bSDavid Young.. code-block:: c
92*41dd9a6bSDavid Young
93*41dd9a6bSDavid Young  struct rte_eth_dev_info {
94*41dd9a6bSDavid Young      ...
95*41dd9a6bSDavid Young      uint32_t dev_flags; /**< Device flags */
96*41dd9a6bSDavid Young      ...
97*41dd9a6bSDavid Young  };
98*41dd9a6bSDavid Young
99*41dd9a6bSDavid Young- The device or group relationship of ports can be discovered using the
100*41dd9a6bSDavid Young  switch ``domain_id`` field within the devices switch information structure. By
101*41dd9a6bSDavid Young  default the switch ``domain_id`` of a port will be
102*41dd9a6bSDavid Young  ``RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID`` to indicate that the port doesn't
103*41dd9a6bSDavid Young  support the concept of a switch domain, but ports which do support the concept
104*41dd9a6bSDavid Young  will be allocated a unique switch ``domain_id``, ports within the same switch
105*41dd9a6bSDavid Young  domain will share the same ``domain_id``. The switch ``port_id`` is used to
106*41dd9a6bSDavid Young  specify the port_id in terms of the switch, so in the case of SR-IOV devices
107*41dd9a6bSDavid Young  the switch ``port_id`` would represent the virtual function identifier of the
108*41dd9a6bSDavid Young  port.
109*41dd9a6bSDavid Young
110*41dd9a6bSDavid Young.. code-block:: c
111*41dd9a6bSDavid Young
112*41dd9a6bSDavid Young   /**
113*41dd9a6bSDavid Young    * Ethernet device associated switch information
114*41dd9a6bSDavid Young    */
115*41dd9a6bSDavid Young   struct rte_eth_switch_info {
116*41dd9a6bSDavid Young       const char *name; /**< switch name */
117*41dd9a6bSDavid Young       uint16_t domain_id; /**< switch domain id */
118*41dd9a6bSDavid Young       uint16_t port_id; /**< switch port id */
119*41dd9a6bSDavid Young   };
120*41dd9a6bSDavid Young
121*41dd9a6bSDavid Young
122*41dd9a6bSDavid Young.. [1] `Ethernet switch device driver model (switchdev)
123*41dd9a6bSDavid Young       <https://www.kernel.org/doc/Documentation/networking/switchdev.txt>`_
124*41dd9a6bSDavid Young
125*41dd9a6bSDavid Young- For some PMDs, memory usage of representors is huge when number of
126*41dd9a6bSDavid Young  representor grows, mbufs are allocated for each descriptor of Rx queue.
127*41dd9a6bSDavid Young  Polling large number of ports brings more CPU load, cache miss and
128*41dd9a6bSDavid Young  latency. Shared Rx queue can be used to share Rx queue between PF and
129*41dd9a6bSDavid Young  representors among same Rx domain. ``RTE_ETH_DEV_CAPA_RXQ_SHARE`` in
130*41dd9a6bSDavid Young  device info is used to indicate the capability. Setting non-zero share
131*41dd9a6bSDavid Young  group in Rx queue configuration to enable share, share_qid is used to
132*41dd9a6bSDavid Young  identify the shared Rx queue in group. Polling any member port can
133*41dd9a6bSDavid Young  receive packets of all member ports in the group, port ID is saved in
134*41dd9a6bSDavid Young  ``mbuf.port``.
135*41dd9a6bSDavid Young
136*41dd9a6bSDavid YoungBasic SR-IOV
137*41dd9a6bSDavid Young------------
138*41dd9a6bSDavid Young
139*41dd9a6bSDavid Young"Basic" in the sense that it is not managed by applications, which
140*41dd9a6bSDavid Youngnonetheless expect traffic to flow between the various endpoints and the
141*41dd9a6bSDavid Youngoutside as if everything was linked by an Ethernet hub.
142*41dd9a6bSDavid Young
143*41dd9a6bSDavid YoungThe following diagram pictures a setup involving a device with one PF, two
144*41dd9a6bSDavid YoungVFs and one shared physical port
145*41dd9a6bSDavid Young
146*41dd9a6bSDavid Young::
147*41dd9a6bSDavid Young
148*41dd9a6bSDavid Young       .-------------.                 .-------------. .-------------.
149*41dd9a6bSDavid Young       | hypervisor  |                 |    VM 1     | |    VM 2     |
150*41dd9a6bSDavid Young       | application |                 | application | | application |
151*41dd9a6bSDavid Young       `--+----------'                 `----------+--' `--+----------'
152*41dd9a6bSDavid Young          |                                       |       |
153*41dd9a6bSDavid Young    .-----+-----.                                 |       |
154*41dd9a6bSDavid Young    | port_id 3 |                                 |       |
155*41dd9a6bSDavid Young    `-----+-----'                                 |       |
156*41dd9a6bSDavid Young          |                                       |       |
157*41dd9a6bSDavid Young        .-+--.                                .---+--. .--+---.
158*41dd9a6bSDavid Young        | PF |                                | VF 1 | | VF 2 |
159*41dd9a6bSDavid Young        `-+--'                                `---+--' `--+---'
160*41dd9a6bSDavid Young          |                                       |       |
161*41dd9a6bSDavid Young          `---------.     .-----------------------'       |
162*41dd9a6bSDavid Young                    |     |     .-------------------------'
163*41dd9a6bSDavid Young                    |     |     |
164*41dd9a6bSDavid Young                 .--+-----+-----+--.
165*41dd9a6bSDavid Young                 | interconnection |
166*41dd9a6bSDavid Young                 `--------+--------'
167*41dd9a6bSDavid Young                          |
168*41dd9a6bSDavid Young                     .----+-----.
169*41dd9a6bSDavid Young                     | physical |
170*41dd9a6bSDavid Young                     |  port 0  |
171*41dd9a6bSDavid Young                     `----------'
172*41dd9a6bSDavid Young
173*41dd9a6bSDavid Young- A DPDK application running on the hypervisor owns the PF device, which is
174*41dd9a6bSDavid Young  arbitrarily assigned port index 3.
175*41dd9a6bSDavid Young
176*41dd9a6bSDavid Young- Both VFs are assigned to VMs and used by unknown applications; they may be
177*41dd9a6bSDavid Young  DPDK-based or anything else.
178*41dd9a6bSDavid Young
179*41dd9a6bSDavid Young- Interconnection is not necessarily done through a true Ethernet switch and
180*41dd9a6bSDavid Young  may not even exist as a separate entity. The role of this block is to show
181*41dd9a6bSDavid Young  that something brings PF, VFs and physical ports together and enables
182*41dd9a6bSDavid Young  communication between them, with a number of built-in restrictions.
183*41dd9a6bSDavid Young
184*41dd9a6bSDavid YoungSubsequent sections in this document describe means for DPDK applications
185*41dd9a6bSDavid Youngrunning on the hypervisor to freely assign specific flows between PF, VFs
186*41dd9a6bSDavid Youngand physical ports based on traffic properties, by managing this
187*41dd9a6bSDavid Younginterconnection.
188*41dd9a6bSDavid Young
189*41dd9a6bSDavid YoungControlled SR-IOV
190*41dd9a6bSDavid Young-----------------
191*41dd9a6bSDavid Young
192*41dd9a6bSDavid YoungInitialization
193*41dd9a6bSDavid Young~~~~~~~~~~~~~~
194*41dd9a6bSDavid Young
195*41dd9a6bSDavid YoungWhen a DPDK application gets assigned a PF device and is deliberately not
196*41dd9a6bSDavid Youngstarted in `basic SR-IOV`_ mode, any traffic coming from physical ports is
197*41dd9a6bSDavid Youngreceived by PF according to default rules, while VFs remain isolated.
198*41dd9a6bSDavid Young
199*41dd9a6bSDavid Young::
200*41dd9a6bSDavid Young
201*41dd9a6bSDavid Young       .-------------.                 .-------------. .-------------.
202*41dd9a6bSDavid Young       | hypervisor  |                 |    VM 1     | |    VM 2     |
203*41dd9a6bSDavid Young       | application |                 | application | | application |
204*41dd9a6bSDavid Young       `--+----------'                 `----------+--' `--+----------'
205*41dd9a6bSDavid Young          |                                       |       |
206*41dd9a6bSDavid Young    .-----+-----.                                 |       |
207*41dd9a6bSDavid Young    | port_id 3 |                                 |       |
208*41dd9a6bSDavid Young    `-----+-----'                                 |       |
209*41dd9a6bSDavid Young          |                                       |       |
210*41dd9a6bSDavid Young        .-+--.                                .---+--. .--+---.
211*41dd9a6bSDavid Young        | PF |                                | VF 1 | | VF 2 |
212*41dd9a6bSDavid Young        `-+--'                                `------' `------'
213*41dd9a6bSDavid Young          |
214*41dd9a6bSDavid Young          `-----.
215*41dd9a6bSDavid Young                |
216*41dd9a6bSDavid Young             .--+----------------------.
217*41dd9a6bSDavid Young             | managed interconnection |
218*41dd9a6bSDavid Young             `------------+------------'
219*41dd9a6bSDavid Young                          |
220*41dd9a6bSDavid Young                     .----+-----.
221*41dd9a6bSDavid Young                     | physical |
222*41dd9a6bSDavid Young                     |  port 0  |
223*41dd9a6bSDavid Young                     `----------'
224*41dd9a6bSDavid Young
225*41dd9a6bSDavid YoungIn this mode, interconnection must be configured by the application to
226*41dd9a6bSDavid Youngenable VF communication, for instance by explicitly directing traffic with a
227*41dd9a6bSDavid Younggiven destination MAC address to VF 1 and allowing that with the same source
228*41dd9a6bSDavid YoungMAC address to come out of it.
229*41dd9a6bSDavid Young
230*41dd9a6bSDavid YoungFor this to work, hypervisor applications need a way to refer to either VF 1
231*41dd9a6bSDavid Youngor VF 2 in addition to the PF. This is addressed by `VF representors`_.
232*41dd9a6bSDavid Young
233*41dd9a6bSDavid YoungVF Representors
234*41dd9a6bSDavid Young~~~~~~~~~~~~~~~
235*41dd9a6bSDavid Young
236*41dd9a6bSDavid YoungVF representors are virtual but standard DPDK network devices (albeit with
237*41dd9a6bSDavid Younglimited capabilities) created by PMDs when managing a PF device.
238*41dd9a6bSDavid Young
239*41dd9a6bSDavid YoungSince they represent VF instances used by other applications, configuring
240*41dd9a6bSDavid Youngthem (e.g. assigning a MAC address or setting up promiscuous mode) affects
241*41dd9a6bSDavid Younginterconnection accordingly. If supported, they may also be used as two-way
242*41dd9a6bSDavid Youngcommunication ports with VFs (assuming **switchdev** topology)
243*41dd9a6bSDavid Young
244*41dd9a6bSDavid Young
245*41dd9a6bSDavid Young::
246*41dd9a6bSDavid Young
247*41dd9a6bSDavid Young       .-------------.                 .-------------. .-------------.
248*41dd9a6bSDavid Young       | hypervisor  |                 |    VM 1     | |    VM 2     |
249*41dd9a6bSDavid Young       | application |                 | application | | application |
250*41dd9a6bSDavid Young       `--+---+---+--'                 `----------+--' `--+----------'
251*41dd9a6bSDavid Young          |   |   |                               |       |
252*41dd9a6bSDavid Young          |   |   `-------------------.           |       |
253*41dd9a6bSDavid Young          |   `---------.             |           |       |
254*41dd9a6bSDavid Young          |             |             |           |       |
255*41dd9a6bSDavid Young    .-----+-----. .-----+-----. .-----+-----.     |       |
256*41dd9a6bSDavid Young    | port_id 3 | | port_id 4 | | port_id 5 |     |       |
257*41dd9a6bSDavid Young    `-----+-----' `-----+-----' `-----+-----'     |       |
258*41dd9a6bSDavid Young          |             |             |           |       |
259*41dd9a6bSDavid Young        .-+--.    .-----+-----. .-----+-----. .---+--. .--+---.
260*41dd9a6bSDavid Young        | PF |    | VF 1 rep. | | VF 2 rep. | | VF 1 | | VF 2 |
261*41dd9a6bSDavid Young        `-+--'    `-----+-----' `-----+-----' `---+--' `--+---'
262*41dd9a6bSDavid Young          |             |             |           |       |
263*41dd9a6bSDavid Young          |             |   .---------'           |       |
264*41dd9a6bSDavid Young          `-----.       |   |   .-----------------'       |
265*41dd9a6bSDavid Young                |       |   |   |   .---------------------'
266*41dd9a6bSDavid Young                |       |   |   |   |
267*41dd9a6bSDavid Young             .--+-------+---+---+---+--.
268*41dd9a6bSDavid Young             | managed interconnection |
269*41dd9a6bSDavid Young             `------------+------------'
270*41dd9a6bSDavid Young                          |
271*41dd9a6bSDavid Young                     .----+-----.
272*41dd9a6bSDavid Young                     | physical |
273*41dd9a6bSDavid Young                     |  port 0  |
274*41dd9a6bSDavid Young                     `----------'
275*41dd9a6bSDavid Young
276*41dd9a6bSDavid Young- VF representors are assigned arbitrary port indices 4 and 5 in the
277*41dd9a6bSDavid Young  hypervisor application and are respectively associated with VF 1 and VF 2.
278*41dd9a6bSDavid Young
279*41dd9a6bSDavid Young- They can't be dissociated; even if VF 1 and VF 2 were not connected,
280*41dd9a6bSDavid Young  representors could still be used for configuration.
281*41dd9a6bSDavid Young
282*41dd9a6bSDavid Young- In this context, port index 3 can be thought as a representor for physical
283*41dd9a6bSDavid Young  port 0.
284*41dd9a6bSDavid Young
285*41dd9a6bSDavid YoungAs previously described, the "interconnection" block represents a logical
286*41dd9a6bSDavid Youngconcept. Interconnection occurs when hardware configuration enables traffic
287*41dd9a6bSDavid Youngflows from one place to another (e.g. physical port 0 to VF 1) according to
288*41dd9a6bSDavid Youngsome criteria.
289*41dd9a6bSDavid Young
290*41dd9a6bSDavid YoungThis is discussed in more detail in `traffic steering`_.
291*41dd9a6bSDavid Young
292*41dd9a6bSDavid YoungTraffic Steering
293*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~
294*41dd9a6bSDavid Young
295*41dd9a6bSDavid YoungIn the following diagram, each meaningful traffic origin or endpoint as seen
296*41dd9a6bSDavid Youngby the hypervisor application is tagged with a unique letter from A to F.
297*41dd9a6bSDavid Young
298*41dd9a6bSDavid Young::
299*41dd9a6bSDavid Young
300*41dd9a6bSDavid Young       .-------------.                 .-------------. .-------------.
301*41dd9a6bSDavid Young       | hypervisor  |                 |    VM 1     | |    VM 2     |
302*41dd9a6bSDavid Young       | application |                 | application | | application |
303*41dd9a6bSDavid Young       `--+---+---+--'                 `----------+--' `--+----------'
304*41dd9a6bSDavid Young          |   |   |                               |       |
305*41dd9a6bSDavid Young          |   |   `-------------------.           |       |
306*41dd9a6bSDavid Young          |   `---------.             |           |       |
307*41dd9a6bSDavid Young          |             |             |           |       |
308*41dd9a6bSDavid Young    .----(A)----. .----(B)----. .----(C)----.     |       |
309*41dd9a6bSDavid Young    | port_id 3 | | port_id 4 | | port_id 5 |     |       |
310*41dd9a6bSDavid Young    `-----+-----' `-----+-----' `-----+-----'     |       |
311*41dd9a6bSDavid Young          |             |             |           |       |
312*41dd9a6bSDavid Young        .-+--.    .-----+-----. .-----+-----. .---+--. .--+---.
313*41dd9a6bSDavid Young        | PF |    | VF 1 rep. | | VF 2 rep. | | VF 1 | | VF 2 |
314*41dd9a6bSDavid Young        `-+--'    `-----+-----' `-----+-----' `--(D)-' `-(E)--'
315*41dd9a6bSDavid Young          |             |             |           |       |
316*41dd9a6bSDavid Young          |             |   .---------'           |       |
317*41dd9a6bSDavid Young          `-----.       |   |   .-----------------'       |
318*41dd9a6bSDavid Young                |       |   |   |   .---------------------'
319*41dd9a6bSDavid Young                |       |   |   |   |
320*41dd9a6bSDavid Young             .--+-------+---+---+---+--.
321*41dd9a6bSDavid Young             | managed interconnection |
322*41dd9a6bSDavid Young             `------------+------------'
323*41dd9a6bSDavid Young                          |
324*41dd9a6bSDavid Young                     .---(F)----.
325*41dd9a6bSDavid Young                     | physical |
326*41dd9a6bSDavid Young                     |  port 0  |
327*41dd9a6bSDavid Young                     `----------'
328*41dd9a6bSDavid Young
329*41dd9a6bSDavid Young- **A**: PF device.
330*41dd9a6bSDavid Young- **B**: port representor for VF 1.
331*41dd9a6bSDavid Young- **C**: port representor for VF 2.
332*41dd9a6bSDavid Young- **D**: VF 1 proper.
333*41dd9a6bSDavid Young- **E**: VF 2 proper.
334*41dd9a6bSDavid Young- **F**: physical port.
335*41dd9a6bSDavid Young
336*41dd9a6bSDavid YoungAlthough uncommon, some devices do not enforce a one to one mapping between
337*41dd9a6bSDavid YoungPF and physical ports. For instance, by default all ports of **mlx4**
338*41dd9a6bSDavid Youngadapters are available to all their PF/VF instances, in which case
339*41dd9a6bSDavid Youngadditional ports appear next to **F** in the above diagram.
340*41dd9a6bSDavid Young
341*41dd9a6bSDavid YoungAssuming no interconnection is provided by default in this mode, setting up
342*41dd9a6bSDavid Younga `basic SR-IOV`_ configuration involving physical port 0 could be broken
343*41dd9a6bSDavid Youngdown as:
344*41dd9a6bSDavid Young
345*41dd9a6bSDavid YoungPF:
346*41dd9a6bSDavid Young
347*41dd9a6bSDavid Young- **A to F**: let everything through.
348*41dd9a6bSDavid Young- **F to A**: PF MAC as destination.
349*41dd9a6bSDavid Young
350*41dd9a6bSDavid YoungVF 1:
351*41dd9a6bSDavid Young
352*41dd9a6bSDavid Young- **A to D**, **E to D** and **F to D**: VF 1 MAC as destination.
353*41dd9a6bSDavid Young- **D to A**: VF 1 MAC as source and PF MAC as destination.
354*41dd9a6bSDavid Young- **D to E**: VF 1 MAC as source and VF 2 MAC as destination.
355*41dd9a6bSDavid Young- **D to F**: VF 1 MAC as source.
356*41dd9a6bSDavid Young
357*41dd9a6bSDavid YoungVF 2:
358*41dd9a6bSDavid Young
359*41dd9a6bSDavid Young- **A to E**, **D to E** and **F to E**: VF 2 MAC as destination.
360*41dd9a6bSDavid Young- **E to A**: VF 2 MAC as source and PF MAC as destination.
361*41dd9a6bSDavid Young- **E to D**: VF 2 MAC as source and VF 1 MAC as destination.
362*41dd9a6bSDavid Young- **E to F**: VF 2 MAC as source.
363*41dd9a6bSDavid Young
364*41dd9a6bSDavid YoungDevices may additionally support advanced matching criteria such as
365*41dd9a6bSDavid YoungIPv4/IPv6 addresses or TCP/UDP ports.
366*41dd9a6bSDavid Young
367*41dd9a6bSDavid YoungThe combination of matching criteria with target endpoints fits well with
368*41dd9a6bSDavid Young**rte_flow** [6]_, which expresses flow rules as combinations of patterns
369*41dd9a6bSDavid Youngand actions.
370*41dd9a6bSDavid Young
371*41dd9a6bSDavid YoungEnhancing **rte_flow** with the ability to make flow rules match and target
372*41dd9a6bSDavid Youngthese endpoints provides a standard interface to manage their
373*41dd9a6bSDavid Younginterconnection without introducing new concepts and whole new API to
374*41dd9a6bSDavid Youngimplement them. This is described in [6]_.
375*41dd9a6bSDavid Young
376*41dd9a6bSDavid Young.. [6] :doc:`flow_offload`
377*41dd9a6bSDavid Young
378*41dd9a6bSDavid YoungFlow API (rte_flow)
379*41dd9a6bSDavid Young-------------------
380*41dd9a6bSDavid Young
381*41dd9a6bSDavid YoungExtensions
382*41dd9a6bSDavid Young~~~~~~~~~~
383*41dd9a6bSDavid Young
384*41dd9a6bSDavid YoungCompared to creating a brand new dedicated interface, **rte_flow** was
385*41dd9a6bSDavid Youngdeemed flexible enough to manage representor traffic only with minor
386*41dd9a6bSDavid Youngextensions:
387*41dd9a6bSDavid Young
388*41dd9a6bSDavid Young- Using physical ports, PF, SF, VF or port representors as targets.
389*41dd9a6bSDavid Young
390*41dd9a6bSDavid Young- Affecting traffic that is not necessarily addressed to the DPDK port ID a
391*41dd9a6bSDavid Young  flow rule is associated with (e.g. forcing VF traffic redirection to PF).
392*41dd9a6bSDavid Young
393*41dd9a6bSDavid YoungFor advanced uses:
394*41dd9a6bSDavid Young
395*41dd9a6bSDavid Young- Rule-based packet counters.
396*41dd9a6bSDavid Young
397*41dd9a6bSDavid Young- The ability to combine several identical actions for traffic duplication
398*41dd9a6bSDavid Young  (e.g. VF representor in addition to a physical port).
399*41dd9a6bSDavid Young
400*41dd9a6bSDavid Young- Dedicated actions for traffic encapsulation / decapsulation before
401*41dd9a6bSDavid Young  reaching an endpoint.
402*41dd9a6bSDavid Young
403*41dd9a6bSDavid YoungTraffic Direction
404*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~
405*41dd9a6bSDavid Young
406*41dd9a6bSDavid YoungFrom an application standpoint, "ingress" and "egress" flow rule attributes
407*41dd9a6bSDavid Youngapply to the DPDK port ID they are associated with. They select a traffic
408*41dd9a6bSDavid Youngdirection for matching patterns, but have no impact on actions.
409*41dd9a6bSDavid Young
410*41dd9a6bSDavid YoungWhen matching traffic coming from or going to a different place than the
411*41dd9a6bSDavid Youngimmediate port ID a flow rule is associated with, these attributes keep
412*41dd9a6bSDavid Youngtheir meaning while applying to the chosen origin, as highlighted by the
413*41dd9a6bSDavid Youngfollowing diagram
414*41dd9a6bSDavid Young
415*41dd9a6bSDavid Young::
416*41dd9a6bSDavid Young
417*41dd9a6bSDavid Young       .-------------.                 .-------------. .-------------.
418*41dd9a6bSDavid Young       | hypervisor  |                 |    VM 1     | |    VM 2     |
419*41dd9a6bSDavid Young       | application |                 | application | | application |
420*41dd9a6bSDavid Young       `--+---+---+--'                 `----------+--' `--+----------'
421*41dd9a6bSDavid Young          |   |   |                               |       |
422*41dd9a6bSDavid Young          |   |   `-------------------.           |       |
423*41dd9a6bSDavid Young          |   `---------.             |           |       |
424*41dd9a6bSDavid Young          | ^           | ^           | ^         |       |
425*41dd9a6bSDavid Young          | | ingress   | | ingress   | | ingress |       |
426*41dd9a6bSDavid Young          | | egress    | | egress    | | egress  |       |
427*41dd9a6bSDavid Young          | v           | v           | v         |       |
428*41dd9a6bSDavid Young    .----(A)----. .----(B)----. .----(C)----.     |       |
429*41dd9a6bSDavid Young    | port_id 3 | | port_id 4 | | port_id 5 |     |       |
430*41dd9a6bSDavid Young    `-----+-----' `-----+-----' `-----+-----'     |       |
431*41dd9a6bSDavid Young          |             |             |           |       |
432*41dd9a6bSDavid Young        .-+--.    .-----+-----. .-----+-----. .---+--. .--+---.
433*41dd9a6bSDavid Young        | PF |    | VF 1 rep. | | VF 2 rep. | | VF 1 | | VF 2 |
434*41dd9a6bSDavid Young        `-+--'    `-----+-----' `-----+-----' `--(D)-' `-(E)--'
435*41dd9a6bSDavid Young          |             |             |         ^ |       | ^
436*41dd9a6bSDavid Young          |             |             |  egress | |       | | egress
437*41dd9a6bSDavid Young          |             |             | ingress | |       | | ingress
438*41dd9a6bSDavid Young          |             |   .---------'         v |       | v
439*41dd9a6bSDavid Young          `-----.       |   |   .-----------------'       |
440*41dd9a6bSDavid Young                |       |   |   |   .---------------------'
441*41dd9a6bSDavid Young                |       |   |   |   |
442*41dd9a6bSDavid Young             .--+-------+---+---+---+--.
443*41dd9a6bSDavid Young             | managed interconnection |
444*41dd9a6bSDavid Young             `------------+------------'
445*41dd9a6bSDavid Young                        ^ |
446*41dd9a6bSDavid Young                ingress | |
447*41dd9a6bSDavid Young                 egress | |
448*41dd9a6bSDavid Young                        v |
449*41dd9a6bSDavid Young                     .---(F)----.
450*41dd9a6bSDavid Young                     | physical |
451*41dd9a6bSDavid Young                     |  port 0  |
452*41dd9a6bSDavid Young                     `----------'
453*41dd9a6bSDavid Young
454*41dd9a6bSDavid YoungIngress and egress are defined as relative to the application creating the
455*41dd9a6bSDavid Youngflow rule.
456*41dd9a6bSDavid Young
457*41dd9a6bSDavid YoungFor instance, matching traffic sent by VM 2 would be done through an ingress
458*41dd9a6bSDavid Youngflow rule on VF 2 (**E**). Likewise for incoming traffic on physical port
459*41dd9a6bSDavid Young(**F**). This also applies to **C** and **A** respectively.
460*41dd9a6bSDavid Young
461*41dd9a6bSDavid YoungTransferring Traffic
462*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~~~~
463*41dd9a6bSDavid Young
464*41dd9a6bSDavid YoungWithout Port Representors
465*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^^^^^^
466*41dd9a6bSDavid Young
467*41dd9a6bSDavid Young`Traffic direction`_ describes how an application could match traffic coming
468*41dd9a6bSDavid Youngfrom or going to a specific place reachable from a DPDK port ID. This makes
469*41dd9a6bSDavid Youngsense when the traffic in question is normally seen (i.e. sent or received)
470*41dd9a6bSDavid Youngby the application creating the flow rule.
471*41dd9a6bSDavid Young
472*41dd9a6bSDavid YoungHowever, if there is an entity (VF **D**, for instance) not associated with
473*41dd9a6bSDavid Younga DPDK port (representor), the application (**A**) won't be able to match
474*41dd9a6bSDavid Youngtraffic generated by such entity. The traffic goes directly to its
475*41dd9a6bSDavid Youngdefault destination (to physical port **F**, for instance).
476*41dd9a6bSDavid Young
477*41dd9a6bSDavid Young::
478*41dd9a6bSDavid Young
479*41dd9a6bSDavid Young    .-------------. .-------------.
480*41dd9a6bSDavid Young    | hypervisor  | |    VM 1     |
481*41dd9a6bSDavid Young    | application | | application |
482*41dd9a6bSDavid Young    `------+------' `--+----------'
483*41dd9a6bSDavid Young           |           | | traffic
484*41dd9a6bSDavid Young     .----(A)----.     | v
485*41dd9a6bSDavid Young     | port_id 3 |     |
486*41dd9a6bSDavid Young     `-----+-----'     |
487*41dd9a6bSDavid Young           |           |
488*41dd9a6bSDavid Young           |           |
489*41dd9a6bSDavid Young         .-+--.    .---+--.
490*41dd9a6bSDavid Young         | PF |    | VF 1 |
491*41dd9a6bSDavid Young         `-+--'    `--(D)-'
492*41dd9a6bSDavid Young           |           | | traffic
493*41dd9a6bSDavid Young           |           | v
494*41dd9a6bSDavid Young        .--+-----------+--.
495*41dd9a6bSDavid Young        | interconnection |
496*41dd9a6bSDavid Young        `--------+--------'
497*41dd9a6bSDavid Young                 | | traffic
498*41dd9a6bSDavid Young                 | v
499*41dd9a6bSDavid Young            .---(F)----.
500*41dd9a6bSDavid Young            | physical |
501*41dd9a6bSDavid Young            |  port 0  |
502*41dd9a6bSDavid Young            `----------'
503*41dd9a6bSDavid Young
504*41dd9a6bSDavid Young
505*41dd9a6bSDavid YoungWith Port Representors
506*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^^^
507*41dd9a6bSDavid Young
508*41dd9a6bSDavid YoungWhen port representors exist, implicit flow rules with the "transfer"
509*41dd9a6bSDavid Youngattribute (described in `without port representors`_) are be assumed to
510*41dd9a6bSDavid Youngexist between them and their represented resources. These may be immutable.
511*41dd9a6bSDavid Young
512*41dd9a6bSDavid YoungIn this case, traffic is received by default through the representor and
513*41dd9a6bSDavid Youngneither the "transfer" attribute nor traffic origin in flow rule patterns
514*41dd9a6bSDavid Youngare necessary. They simply have to be created on the representor port
515*41dd9a6bSDavid Youngdirectly and may target a different representor as described
516*41dd9a6bSDavid Youngin `PORT_REPRESENTOR Action`_.
517*41dd9a6bSDavid Young
518*41dd9a6bSDavid YoungImplicit traffic flow with port representor
519*41dd9a6bSDavid Young
520*41dd9a6bSDavid Young::
521*41dd9a6bSDavid Young
522*41dd9a6bSDavid Young       .-------------.   .-------------.
523*41dd9a6bSDavid Young       | hypervisor  |   |    VM 1     |
524*41dd9a6bSDavid Young       | application |   | application |
525*41dd9a6bSDavid Young       `--+-------+--'   `----------+--'
526*41dd9a6bSDavid Young          |       | ^               | | traffic
527*41dd9a6bSDavid Young          |       | | traffic       | v
528*41dd9a6bSDavid Young          |       `-----.           |
529*41dd9a6bSDavid Young          |             |           |
530*41dd9a6bSDavid Young    .----(A)----. .----(B)----.     |
531*41dd9a6bSDavid Young    | port_id 3 | | port_id 4 |     |
532*41dd9a6bSDavid Young    `-----+-----' `-----+-----'     |
533*41dd9a6bSDavid Young          |             |           |
534*41dd9a6bSDavid Young        .-+--.    .-----+-----. .---+--.
535*41dd9a6bSDavid Young        | PF |    | VF 1 rep. | | VF 1 |
536*41dd9a6bSDavid Young        `-+--'    `-----+-----' `--(D)-'
537*41dd9a6bSDavid Young          |             |           |
538*41dd9a6bSDavid Young       .--|-------------|-----------|--.
539*41dd9a6bSDavid Young       |  |             |           |  |
540*41dd9a6bSDavid Young       |  |             `-----------'  |
541*41dd9a6bSDavid Young       |  |              <-- traffic   |
542*41dd9a6bSDavid Young       `--|----------------------------'
543*41dd9a6bSDavid Young          |
544*41dd9a6bSDavid Young     .---(F)----.
545*41dd9a6bSDavid Young     | physical |
546*41dd9a6bSDavid Young     |  port 0  |
547*41dd9a6bSDavid Young     `----------'
548*41dd9a6bSDavid Young
549*41dd9a6bSDavid YoungPattern Items And Actions
550*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~~~~~~~~~
551*41dd9a6bSDavid Young
552*41dd9a6bSDavid YoungPORT_REPRESENTOR Pattern Item
553*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
554*41dd9a6bSDavid Young
555*41dd9a6bSDavid YoungMatches traffic entering the embedded switch from the given ethdev.
556*41dd9a6bSDavid Young
557*41dd9a6bSDavid Young- Matches **A**, **B** or **C** in `traffic steering`_.
558*41dd9a6bSDavid Young
559*41dd9a6bSDavid YoungPORT_REPRESENTOR Action
560*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^^^^
561*41dd9a6bSDavid Young
562*41dd9a6bSDavid YoungAt embedded switch level, sends matching traffic to the given ethdev.
563*41dd9a6bSDavid Young
564*41dd9a6bSDavid Young- Targets **A**, **B** or **C** in `traffic steering`_.
565*41dd9a6bSDavid Young
566*41dd9a6bSDavid YoungREPRESENTED_PORT Pattern Item
567*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
568*41dd9a6bSDavid Young
569*41dd9a6bSDavid YoungMatches traffic entering the embedded switch from
570*41dd9a6bSDavid Youngthe entity represented by the given ethdev.
571*41dd9a6bSDavid Young
572*41dd9a6bSDavid Young- Matches **D**, **E** or **F** in `traffic steering`_.
573*41dd9a6bSDavid Young
574*41dd9a6bSDavid YoungREPRESENTED_PORT Action
575*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^^^^
576*41dd9a6bSDavid Young
577*41dd9a6bSDavid YoungAt embedded switch level, send matching traffic to
578*41dd9a6bSDavid Youngthe entity represented by the given ethdev.
579*41dd9a6bSDavid Young
580*41dd9a6bSDavid Young- Targets **D**, **E** or **F** in `traffic steering`_.
581*41dd9a6bSDavid Young
582*41dd9a6bSDavid YoungPORT Pattern Item
583*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^
584*41dd9a6bSDavid Young
585*41dd9a6bSDavid YoungMatches traffic originating from (ingress) or going to (egress) a physical
586*41dd9a6bSDavid Youngport of the underlying device.
587*41dd9a6bSDavid Young
588*41dd9a6bSDavid YoungUsing this pattern item without specifying a port index matches the physical
589*41dd9a6bSDavid Youngport associated with the current DPDK port ID by default. As described in
590*41dd9a6bSDavid Young`traffic steering`_, specifying it should be rarely needed.
591*41dd9a6bSDavid Young
592*41dd9a6bSDavid Young- Matches **F** in `traffic steering`_.
593*41dd9a6bSDavid Young
594*41dd9a6bSDavid YoungPORT Action
595*41dd9a6bSDavid Young^^^^^^^^^^^
596*41dd9a6bSDavid Young
597*41dd9a6bSDavid YoungDirects matching traffic to a given physical port index.
598*41dd9a6bSDavid Young
599*41dd9a6bSDavid Young- Targets **F** in `traffic steering`_.
600*41dd9a6bSDavid Young
601*41dd9a6bSDavid YoungPORT_ID Pattern Item
602*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^^^^^
603*41dd9a6bSDavid Young
604*41dd9a6bSDavid YoungMatches traffic originating from (ingress) or going to (egress) a given DPDK
605*41dd9a6bSDavid Youngport ID.
606*41dd9a6bSDavid Young
607*41dd9a6bSDavid YoungNormally only supported if the port ID in question is known by the
608*41dd9a6bSDavid Youngunderlying PMD and related to the device the flow rule is created against.
609*41dd9a6bSDavid Young
610*41dd9a6bSDavid YoungThis must not be confused with the `PORT pattern item`_ which refers to the
611*41dd9a6bSDavid Youngphysical port of a device. ``PORT_ID`` refers to a ``struct rte_eth_dev``
612*41dd9a6bSDavid Youngobject on the application side (also known as "port representor" depending
613*41dd9a6bSDavid Youngon the kind of underlying device).
614*41dd9a6bSDavid Young
615*41dd9a6bSDavid Young- Matches **A**, **B** or **C** in `traffic steering`_.
616*41dd9a6bSDavid Young
617*41dd9a6bSDavid YoungPORT_ID Action
618*41dd9a6bSDavid Young^^^^^^^^^^^^^^
619*41dd9a6bSDavid Young
620*41dd9a6bSDavid YoungDirects matching traffic to a given DPDK port ID.
621*41dd9a6bSDavid Young
622*41dd9a6bSDavid YoungSame restrictions as `PORT_ID pattern item`_.
623*41dd9a6bSDavid Young
624*41dd9a6bSDavid Young- Targets **A**, **B** or **C** in `traffic steering`_.
625*41dd9a6bSDavid Young
626*41dd9a6bSDavid YoungPF Action
627*41dd9a6bSDavid Young^^^^^^^^^
628*41dd9a6bSDavid Young
629*41dd9a6bSDavid YoungDirects matching traffic to the physical function of the current device.
630*41dd9a6bSDavid Young
631*41dd9a6bSDavid Young- Targets **A** in `traffic steering`_.
632*41dd9a6bSDavid Young
633*41dd9a6bSDavid YoungVF Pattern Item
634*41dd9a6bSDavid Young^^^^^^^^^^^^^^^
635*41dd9a6bSDavid Young
636*41dd9a6bSDavid YoungMatches traffic originating from (ingress) or going to (egress) a given
637*41dd9a6bSDavid Youngvirtual function of the current device.
638*41dd9a6bSDavid Young
639*41dd9a6bSDavid YoungIf supported, should work even if the virtual function is not managed by
640*41dd9a6bSDavid Youngthe application and thus not associated with a DPDK port ID. Its behavior is
641*41dd9a6bSDavid Youngotherwise similar to `PORT_ID pattern item`_ using VF port ID.
642*41dd9a6bSDavid Young
643*41dd9a6bSDavid YoungNote this pattern item does not match VF representors traffic which, as
644*41dd9a6bSDavid Youngseparate entities, should be addressed through their own port IDs.
645*41dd9a6bSDavid Young
646*41dd9a6bSDavid Young- Matches **D** or **E** in `traffic steering`_.
647*41dd9a6bSDavid Young
648*41dd9a6bSDavid YoungVF Action
649*41dd9a6bSDavid Young^^^^^^^^^
650*41dd9a6bSDavid Young
651*41dd9a6bSDavid YoungDirects matching traffic to a given virtual function of the current device.
652*41dd9a6bSDavid Young
653*41dd9a6bSDavid YoungSame restrictions as `VF pattern item`_.
654*41dd9a6bSDavid Young
655*41dd9a6bSDavid Young- Targets **D** or **E** in `traffic steering`_.
656*41dd9a6bSDavid Young
657*41dd9a6bSDavid Young\*_ENCAP actions
658*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^
659*41dd9a6bSDavid Young
660*41dd9a6bSDavid YoungThese actions are named according to the protocol they encapsulate traffic
661*41dd9a6bSDavid Youngwith (e.g. ``VXLAN_ENCAP``) and using specific parameters (e.g. VNI for
662*41dd9a6bSDavid YoungVXLAN).
663*41dd9a6bSDavid Young
664*41dd9a6bSDavid YoungWhile they modify traffic and can be used multiple times (order matters),
665*41dd9a6bSDavid Youngunlike `PORT_REPRESENTOR Action`_ and friends, they don't impact on steering.
666*41dd9a6bSDavid Young
667*41dd9a6bSDavid YoungAs described in `actions order and repetition`_ this means they are useless
668*41dd9a6bSDavid Youngif used alone in an action list, the resulting traffic gets dropped unless
669*41dd9a6bSDavid Youngcombined with either ``PASSTHRU`` or other endpoint-targeting actions.
670*41dd9a6bSDavid Young
671*41dd9a6bSDavid Young\*_DECAP actions
672*41dd9a6bSDavid Young^^^^^^^^^^^^^^^^
673*41dd9a6bSDavid Young
674*41dd9a6bSDavid YoungThey perform the reverse of `\*_ENCAP actions`_ by popping protocol headers
675*41dd9a6bSDavid Youngfrom traffic instead of pushing them. They can be used multiple times as
676*41dd9a6bSDavid Youngwell.
677*41dd9a6bSDavid Young
678*41dd9a6bSDavid YoungNote that using these actions on non-matching traffic results in undefined
679*41dd9a6bSDavid Youngbehavior. It is recommended to match the protocol headers to decapsulate on
680*41dd9a6bSDavid Youngthe pattern side of a flow rule in order to use these actions or otherwise
681*41dd9a6bSDavid Youngmake sure only matching traffic goes through.
682*41dd9a6bSDavid Young
683*41dd9a6bSDavid YoungActions Order and Repetition
684*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~~~~~~~~~~~~
685*41dd9a6bSDavid Young
686*41dd9a6bSDavid YoungFlow rules are currently restricted to at most a single action of each
687*41dd9a6bSDavid Youngsupported type, performed in an unpredictable order (or all at once). To
688*41dd9a6bSDavid Youngrepeat actions in a predictable fashion, applications have to make rules
689*41dd9a6bSDavid Youngpass-through and use priority levels.
690*41dd9a6bSDavid Young
691*41dd9a6bSDavid YoungIt's now clear that PMD support for chaining multiple non-terminating flow
692*41dd9a6bSDavid Youngrules of varying priority levels is prohibitively difficult to implement
693*41dd9a6bSDavid Youngcompared to simply allowing multiple identical actions performed in a
694*41dd9a6bSDavid Youngdefined order by a single flow rule.
695*41dd9a6bSDavid Young
696*41dd9a6bSDavid Young- This change is required to support protocol encapsulation offloads and the
697*41dd9a6bSDavid Young  ability to perform them multiple times (e.g. VLAN then VXLAN).
698*41dd9a6bSDavid Young
699*41dd9a6bSDavid Young- It makes the ``DUP`` action redundant since multiple ``QUEUE`` actions can
700*41dd9a6bSDavid Young  be combined for duplication.
701*41dd9a6bSDavid Young
702*41dd9a6bSDavid Young- The (non-)terminating property of actions must be discarded. Instead, flow
703*41dd9a6bSDavid Young  rules themselves must be considered terminating by default (i.e. dropping
704*41dd9a6bSDavid Young  traffic if there is no specific target) unless a ``PASSTHRU`` action is
705*41dd9a6bSDavid Young  also specified.
706*41dd9a6bSDavid Young
707*41dd9a6bSDavid YoungSwitching Examples
708*41dd9a6bSDavid Young------------------
709*41dd9a6bSDavid Young
710*41dd9a6bSDavid YoungThis section provides practical examples based on the established testpmd
711*41dd9a6bSDavid Youngflow command syntax [2]_, in the context described in `traffic steering`_
712*41dd9a6bSDavid Young
713*41dd9a6bSDavid Young::
714*41dd9a6bSDavid Young
715*41dd9a6bSDavid Young      .-------------.                 .-------------. .-------------.
716*41dd9a6bSDavid Young      | hypervisor  |                 |    VM 1     | |    VM 2     |
717*41dd9a6bSDavid Young      | application |                 | application | | application |
718*41dd9a6bSDavid Young      `--+---+---+--'                 `----------+--' `--+----------'
719*41dd9a6bSDavid Young         |   |   |                               |       |
720*41dd9a6bSDavid Young         |   |   `-------------------.           |       |
721*41dd9a6bSDavid Young         |   `---------.             |           |       |
722*41dd9a6bSDavid Young         |             |             |           |       |
723*41dd9a6bSDavid Young   .----(A)----. .----(B)----. .----(C)----.     |       |
724*41dd9a6bSDavid Young   | port_id 3 | | port_id 4 | | port_id 5 |     |       |
725*41dd9a6bSDavid Young   `-----+-----' `-----+-----' `-----+-----'     |       |
726*41dd9a6bSDavid Young         |             |             |           |       |
727*41dd9a6bSDavid Young       .-+--.    .-----+-----. .-----+-----. .---+--. .--+---.
728*41dd9a6bSDavid Young       | PF |    | VF 1 rep. | | VF 2 rep. | | VF 1 | | VF 2 |
729*41dd9a6bSDavid Young       `-+--'    `-----+-----' `-----+-----' `--(D)-' `-(E)--'
730*41dd9a6bSDavid Young         |             |             |           |       |
731*41dd9a6bSDavid Young         |             |   .---------'           |       |
732*41dd9a6bSDavid Young         `-----.       |   |   .-----------------'       |
733*41dd9a6bSDavid Young               |       |   |   |   .---------------------'
734*41dd9a6bSDavid Young               |       |   |   |   |
735*41dd9a6bSDavid Young            .--|-------|---|---|---|--.
736*41dd9a6bSDavid Young            |  |       |   `---|---'  |
737*41dd9a6bSDavid Young            |  |       `-------'      |
738*41dd9a6bSDavid Young            |  `---------.            |
739*41dd9a6bSDavid Young            `------------|------------'
740*41dd9a6bSDavid Young                         |
741*41dd9a6bSDavid Young                    .---(F)----.
742*41dd9a6bSDavid Young                    | physical |
743*41dd9a6bSDavid Young                    |  port 0  |
744*41dd9a6bSDavid Young                    `----------'
745*41dd9a6bSDavid Young
746*41dd9a6bSDavid YoungBy default, PF (**A**) can communicate with the physical port it is
747*41dd9a6bSDavid Youngassociated with (**F**), while VF 1 (**D**) and VF 2 (**E**) are isolated
748*41dd9a6bSDavid Youngand restricted to communicate with the hypervisor application through their
749*41dd9a6bSDavid Youngrespective representors (**B** and **C**) if supported.
750*41dd9a6bSDavid Young
751*41dd9a6bSDavid YoungExamples in subsequent sections apply to hypervisor applications only and
752*41dd9a6bSDavid Youngare based on port representors **A**, **B** and **C**.
753*41dd9a6bSDavid Young
754*41dd9a6bSDavid Young.. [2] :ref:`Flow syntax <testpmd_rte_flow>`
755*41dd9a6bSDavid Young
756*41dd9a6bSDavid YoungAssociating VF 1 with Physical Port 0
757*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
758*41dd9a6bSDavid Young
759*41dd9a6bSDavid YoungAssign all port traffic (**F**) to VF 1 (**D**) indiscriminately through
760*41dd9a6bSDavid Youngtheir representors
761*41dd9a6bSDavid Young
762*41dd9a6bSDavid Young::
763*41dd9a6bSDavid Young
764*41dd9a6bSDavid Young   flow create 3 transfer
765*41dd9a6bSDavid Young      pattern represented_port ethdev_port_id is 3 / end
766*41dd9a6bSDavid Young      actions represented_port ethdev_port_id 4 / end
767*41dd9a6bSDavid Young
768*41dd9a6bSDavid Young::
769*41dd9a6bSDavid Young
770*41dd9a6bSDavid Young   flow create 3 transfer
771*41dd9a6bSDavid Young      pattern represented_port ethdev_port_id is 4 / end
772*41dd9a6bSDavid Young      actions represented_port ethdev_port_id 3 / end
773*41dd9a6bSDavid Young
774*41dd9a6bSDavid Young
775*41dd9a6bSDavid YoungSharing Broadcasts
776*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~~
777*41dd9a6bSDavid Young
778*41dd9a6bSDavid YoungFrom outside to PF and VFs
779*41dd9a6bSDavid Young
780*41dd9a6bSDavid Young::
781*41dd9a6bSDavid Young
782*41dd9a6bSDavid Young   flow create 3 transfer
783*41dd9a6bSDavid Young      pattern
784*41dd9a6bSDavid Young         represented_port ethdev_port_id is 3 /
785*41dd9a6bSDavid Young         eth dst is ff:ff:ff:ff:ff:ff /
786*41dd9a6bSDavid Young         end
787*41dd9a6bSDavid Young      actions
788*41dd9a6bSDavid Young         port_representor ethdev_port_id 3 /
789*41dd9a6bSDavid Young         represented_port ethdev_port_id 4 /
790*41dd9a6bSDavid Young         represented_port ethdev_port_id 5 /
791*41dd9a6bSDavid Young         end
792*41dd9a6bSDavid Young
793*41dd9a6bSDavid YoungNote ``port_representor ethdev_port_id 3`` is necessary otherwise only VFs would receive matching
794*41dd9a6bSDavid Youngtraffic.
795*41dd9a6bSDavid Young
796*41dd9a6bSDavid YoungFrom PF to outside and VFs
797*41dd9a6bSDavid Young
798*41dd9a6bSDavid Young::
799*41dd9a6bSDavid Young
800*41dd9a6bSDavid Young   flow create 3 transfer
801*41dd9a6bSDavid Young      pattern
802*41dd9a6bSDavid Young         port_representor ethdev_port_id is 3 /
803*41dd9a6bSDavid Young         eth dst is ff:ff:ff:ff:ff:ff /
804*41dd9a6bSDavid Young         end
805*41dd9a6bSDavid Young      actions
806*41dd9a6bSDavid Young         represented_port ethdev_port_id 3 /
807*41dd9a6bSDavid Young         represented_port ethdev_port_id 4 /
808*41dd9a6bSDavid Young         represented_port ethdev_port_id 5 /
809*41dd9a6bSDavid Young         end
810*41dd9a6bSDavid Young
811*41dd9a6bSDavid YoungFrom VFs to outside and PF
812*41dd9a6bSDavid Young
813*41dd9a6bSDavid Young::
814*41dd9a6bSDavid Young
815*41dd9a6bSDavid Young   flow create 3 transfer
816*41dd9a6bSDavid Young      pattern
817*41dd9a6bSDavid Young         represented_port ethdev_port_id is 4 /
818*41dd9a6bSDavid Young         eth dst is ff:ff:ff:ff:ff:ff /
819*41dd9a6bSDavid Young         end
820*41dd9a6bSDavid Young      actions
821*41dd9a6bSDavid Young         represented_port ethdev_port_id 3 /
822*41dd9a6bSDavid Young         port_representor ethdev_port_id 3 /
823*41dd9a6bSDavid Young         end
824*41dd9a6bSDavid Young
825*41dd9a6bSDavid Young   flow create 3 transfer
826*41dd9a6bSDavid Young      pattern
827*41dd9a6bSDavid Young         represented_port ethdev_port_id is 5 /
828*41dd9a6bSDavid Young         eth dst is ff:ff:ff:ff:ff:ff /
829*41dd9a6bSDavid Young         end
830*41dd9a6bSDavid Young      actions
831*41dd9a6bSDavid Young         represented_port ethdev_port_id 3 /
832*41dd9a6bSDavid Young         port_representor ethdev_port_id 3 /
833*41dd9a6bSDavid Young         end
834*41dd9a6bSDavid Young
835*41dd9a6bSDavid YoungSimilar ``33:33:*`` rules based on known MAC addresses should be added for
836*41dd9a6bSDavid YoungIPv6 traffic.
837*41dd9a6bSDavid Young
838*41dd9a6bSDavid YoungEncapsulating VF 2 Traffic in VXLAN
839*41dd9a6bSDavid Young~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
840*41dd9a6bSDavid Young
841*41dd9a6bSDavid YoungAssuming pass-through flow rules are supported
842*41dd9a6bSDavid Young
843*41dd9a6bSDavid Young::
844*41dd9a6bSDavid Young
845*41dd9a6bSDavid Young   flow create 5 ingress
846*41dd9a6bSDavid Young      pattern eth / end
847*41dd9a6bSDavid Young      actions vxlan_encap vni 42 / passthru / end
848*41dd9a6bSDavid Young
849*41dd9a6bSDavid Young::
850*41dd9a6bSDavid Young
851*41dd9a6bSDavid Young   flow create 5 egress
852*41dd9a6bSDavid Young      pattern vxlan vni is 42 / end
853*41dd9a6bSDavid Young      actions vxlan_decap / passthru / end
854*41dd9a6bSDavid Young
855*41dd9a6bSDavid YoungHere ``passthru`` is needed since as described in `actions order and
856*41dd9a6bSDavid Youngrepetition`_, flow rules are otherwise terminating; if supported, a rule
857*41dd9a6bSDavid Youngwithout a target endpoint will drop traffic.
858*41dd9a6bSDavid Young
859*41dd9a6bSDavid YoungWithout pass-through support, ingress encapsulation on the destination
860*41dd9a6bSDavid Youngendpoint might not be supported and action list must provide one
861*41dd9a6bSDavid Young
862*41dd9a6bSDavid Young::
863*41dd9a6bSDavid Young
864*41dd9a6bSDavid Young   flow create 3 transfer
865*41dd9a6bSDavid Young      pattern represented_port ethdev_port_id is 5 / end
866*41dd9a6bSDavid Young      actions vxlan_encap vni 42 / represented_port ethdev_port_id 3 / end
867*41dd9a6bSDavid Young
868*41dd9a6bSDavid Young   flow create 3 transfer
869*41dd9a6bSDavid Young      pattern
870*41dd9a6bSDavid Young         represented_port ethdev_port_id is 3 /
871*41dd9a6bSDavid Young         vxlan vni is 42 /
872*41dd9a6bSDavid Young         end
873*41dd9a6bSDavid Young      actions vxlan_decap / represented_port ethdev_port_id 5 / end
874