public inbox for virtio-comment@lists.linux.dev
 help / color / mirror / Atom feed
From: Parav Pandit <parav@nvidia.com>
To: <virtio-comment@lists.linux.dev>, <mst@redhat.com>, <cohuck@redhat.com>
Cc: <hengqi@linux.alibaba.com>, <sburla@marvell.com>,
	<shahafs@nvidia.com>, <si-wei.liu@oracle.com>,
	<peter.hilber@opensynergy.com>, <jasowang@redhat.com>,
	<xuanzhuo@linux.alibaba.com>, Parav Pandit <parav@nvidia.com>
Subject: [PATCH v11 08/13] virtio-net: Add theory of operation for flow filter
Date: Tue, 4 Jun 2024 16:28:58 +0300	[thread overview]
Message-ID: <20240604132903.2093195-9-parav@nvidia.com> (raw)
In-Reply-To: <20240604132903.2093195-1-parav@nvidia.com>

Currently packet allow/drop interface has following limitations.

1. Driver can either select which MAC and VLANs to consider
for allowing/dropping packets, here, the driver has a
limitation that driver needs to supply full mac
table or full vlan table for each type. Driver cannot add or
delete an individual entry.

2. Driver cannot select mac+vlan combination for which
to allow/drop packet.

3. Driver cannot not set other commonly used packet match fields
such as IP header fields, TCP, UDP, SCP header fields.

4. Driver cannot steer specific packets based on the match
fields to specific receiveq.

5. Driver do not have multiple or dedicated virtqueues to
   perform flow filter requests in accelerated manner in
   the device.

Flow filter as a generic framework overcome above limitations.

As starting point it is useful to support at least two use cases.
a. ARFS
b. ethtool ntuple steering

In future it can be further extended for usecases such as
switching device, connection tracking or may be more.

The flow filter has following properties.

1. It is an extendible object that driver can create, destroy.
2. It belongs to a flow filter group.
3. Each flow filter rule is identified using a unique id,
   has priority, match key, destination(rq) and action(allow/drop).
4. Flow filter key also refers to the mask to learn which fields
   of the packets to match.

This patch adds theory of operation for flow filter functionality.

Fixes: https://github.com/oasis-tcs/virtio-spec/issues/179
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
changelog:
v9->v10:
- updated to refer to device resource object
v6->v7:
- addressed comments from Cornelia
- plenty of grammar corrections suggested by Cornelia
- removed stale reference to flow filter virtqueue
- removed incorrect stale hunk of a label
- removed dependency on feature bit and control vq
- rebased to use device capabilities and device resources
v4->v5:
- to avoid feature bit overlap with rss context patch, pick next
  unique bit 65
v3->v4:
- removed flow filter virtqueue section as dynamic queues are
  not supported currently
v2->v3:
- removed dependency on the dynamic queue creation as the
  infrastructure is not yet ready
v1->v2:
- fixed comments from Heng
- grammar corrections
- spelling corrections
---
 device-types/net/description.tex | 68 ++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/device-types/net/description.tex b/device-types/net/description.tex
index e65cdd5..58d0692 100644
--- a/device-types/net/description.tex
+++ b/device-types/net/description.tex
@@ -2411,6 +2411,74 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
 of the driver's records. In such cases, the driver should allocate additional
 space for the \field{command-specific-result} buffer.
 
+\subsubsection{Flow filter}\label{sec:Device Types / Network Device / Device Operation / Flow filter}
+
+A network device can support one or more flow filter rules. Each flow filter rule
+is applied by matching a packet and then taking an action, such as directing the packet
+to a specific receiveq or dropping the packet. An example of a match is
+matching on specific source and destination IP addresses.
+
+A flow filter rule is a device resource object that consists of a key,
+a processing priority, and an action to either direct a packet to a
+receive queue or drop the packet.
+
+Each rule uses a classifier. The key is matched against the packet using
+a classifier, defining which fields in the packet are matched.
+A classifier resource object consists of one or more field selectors, each with
+a type that specifies the header fields to be matched against, and a mask.
+The mask can match whole fields or parts of a field in a header. Each
+rule resource object depends on the classifier resource object.
+
+When a packet is received, relevant fields are extracted
+(in the same way) from both the packet and the key according to the
+classifier. The resulting field contents are then compared -
+if they are identical the rule action is taken, if they are not, the rule is ignored.
+
+Multiple flow filter rules are part of a group. The rule resource object
+depends on the group. Each rule within a
+group has a rule priority, and each group also has a group priority. For a
+packet, a group with the highest priority is selected first. Within a group,
+rules are applied from highest to lowest priority, until one of the rules
+matches the packet and an action is taken. If all the rules within a group
+are ignored, the group with the next highest priority is selected, and so on.
+
+The driver controls the flow filter rule, classifier and group resource objects using
+administration commands described in
+\ref{sec:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device resource objects}.
+
+\paragraph{Packet processing order}\label{sec:sec:Device Types / Network Device / Device Operation / Flow filter / Packet processing order}
+
+Note that flow filter rules are applied after MAC/VLAN filtering. Flow filter
+rules take precedence over steering: if a flow filter rule results in an action,
+the steering configuration does not apply. The steering configuration only applies
+to packets for which no flow filter rule action was performed. For example,
+incoming packets can be processed in the following order:
+
+\begin{itemize}
+\item apply steering configuration received using control virtqueue commands
+      VIRTIO_NET_CTRL_RX, VIRTIO_NET_CTRL_MAC and VIRTIO_NET_CTRL_VLAN.
+\item apply flow filter rules if any.
+\item if no filter rule applied, apply steering configuration received using command
+      VIRTIO_NET_CTRL_MQ_RSS_CONFIG or as per automatic receive steering.
+\end{itemize}
+
+Some incoming packet processing examples:
+\begin{itemize}
+\item If the packet is dropped by the flow filter rule, RSS
+      steering is ignored for the packet.
+\item If the packet is directed to a specific receiveq using flow filter rule,
+      the RSS steering is ignored for the packet.
+\item If a packet is dropped due to the VIRTIO_NET_CTRL_MAC configuration,
+      both flow filter rules and the RSS steering are ignored for the packet.
+\item If a packet does not match any flow filter rules,
+      the RSS steering is used to select the receiveq for the packet (if enabled).
+\item If there are two flow filter groups configured as group_A and group_B
+      with respective group priorities as 4, and 5; flow filter rules of
+      group_B are applied first having highest group priority, if there is a match,
+      the flow filter rules of group_A are ignored; if there is no match for
+      the flow filter rules in group_B, the flow filter rules of next level group_A are applied.
+\end{itemize}
+
 \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
 Types / Network Device / Legacy Interface: Framing Requirements}
 
-- 
2.34.1


  parent reply	other threads:[~2024-06-04 13:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 13:28 [PATCH v11 00/13] flow filter using basic facilities of capability and resource objects Parav Pandit
2024-06-04 13:28 ` [PATCH v11 01/13] admin: Introduce self group Parav Pandit
2024-06-04 13:28 ` [PATCH v11 02/13] admin: Use already defined names for the legacy commands Parav Pandit
2024-06-04 13:28 ` [PATCH v11 03/13] admin: Add theory of operation for capability admin commands Parav Pandit
2024-06-04 13:28 ` [PATCH v11 04/13] admin: Prepare table for multipage listing Parav Pandit
2024-06-04 13:28 ` [PATCH v11 05/13] admin: Add capability admin commands Parav Pandit
2024-06-04 13:28 ` [PATCH v11 06/13] admin: Add theory of operation for device resource objects Parav Pandit
2024-06-04 13:28 ` [PATCH v11 07/13] admin: Add device resource objects admin commands Parav Pandit
2024-06-04 13:28 ` Parav Pandit [this message]
2024-06-04 13:28 ` [PATCH v11 09/13] virtio-net: Add flow filter capability Parav Pandit
2025-11-18 22:09   ` Michael S. Tsirkin
2025-11-19  3:31     ` Parav Pandit
2024-06-04 13:29 ` [PATCH v11 10/13] virtio-net: Add flow filter group, classifier and rule resource objects Parav Pandit
2024-06-04 13:29 ` [PATCH v11 11/13] virtio-net: Add flow filter device and driver requirements Parav Pandit
2024-06-04 13:29 ` [PATCH v11 12/13] newdevice: Improve the appendix chapter heading to reflect the content Parav Pandit
2024-06-04 13:29 ` [PATCH v11 13/13] newdevice: Extend informative guidance on capability, resource objects Parav Pandit
2024-06-04 17:16 ` [EXTERNAL] [PATCH v11 00/13] flow filter using basic facilities of capability and " Satananda Burla
     [not found] ` <691016c0-b8e4-48f0-a26b-45296102f501@davidwei.uk>
2025-03-03 19:59   ` Michael S. Tsirkin
     [not found]     ` <8aafe201-db57-4ab0-868e-2216b2d03987@davidwei.uk>
2025-03-04  8:50       ` Michael S. Tsirkin
2025-03-04  3:48   ` Parav Pandit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240604132903.2093195-9-parav@nvidia.com \
    --to=parav@nvidia.com \
    --cc=cohuck@redhat.com \
    --cc=hengqi@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.hilber@opensynergy.com \
    --cc=sburla@marvell.com \
    --cc=shahafs@nvidia.com \
    --cc=si-wei.liu@oracle.com \
    --cc=virtio-comment@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox