Skip to contentSkip to conversation

net/ena: support flow API for n-tuple Rx steering

PATCH Superseded Shai Brandes 1 participant 1 message Oct 18

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 11/13 net/ena: support flow API for n-tuple Rx steering

Implement the flow_ops_get ethdev callback to expose hardware n-tuple Rx steering through the rte_flow API, allowing applications to direct selected traffic to dedicated Rx queues for workload isolation.

Supported patterns are IPv4, IPv6, TCP and UDP, matching source and destination addresses, source and destination ports and IP TOS/DSCP. The protocol is derived from the TCP or UDP item type. The only supported action is queue steering to a single Rx queue. Rules are accepted for ingress traffic in group 0 with priority 0. Item spec and mask are honoured, including default masks; ranges specified through the item last field are rejected, as are unsupported header fields.

Flow steering is reported as unsupported when the device exposes no rule entries.

Documented limitations: rules can only be created once the device is started, they are not retained across device stop, and a rule referencing an Rx queue that is removed by a later reconfiguration will cause matching packets to be dropped.

---
 doc/guides/nics/ena.rst                       |  26 +
 doc/guides/nics/features/ena.ini              |  10 +
 doc/guides/rel_notes/release_26_11.rst        |   4 +
 drivers/net/ena/base/ena_com.c                | 300 ++++++++++
 drivers/net/ena/base/ena_com.h                |  86 +++
 .../net/ena/base/ena_defs/ena_admin_defs.h    |  83 ++-
 drivers/net/ena/ena_ethdev.c                  |  71 ++-
 drivers/net/ena/ena_ethdev.h                  |   3 +-
 drivers/net/ena/ena_flow.c                    | 542 ++++++++++++++++++
 drivers/net/ena/ena_flow.h                    |  12 +
 drivers/net/ena/meson.build                   |   1 +
 11 files changed, 1135 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ena/ena_flow.c
 create mode 100644 drivers/net/ena/ena_flow.h
doc/guides/nics/ena.rst +26 -0
index d829e8854f..4c2f0e098a 100644
@@ -33,6 +33,7 @@ Supported features
 * Device reset upon failure
 * Rx interrupts
 * Rx HW packet timestamping
+* Rx flow steering
 
 Overview
 --------
@@ -59,6 +60,9 @@ Queue (LLQ), which saves several more microseconds.
 Rx hardware timestamping is available in the ENA driver
 on platforms that support this feature.
 
+Rx flow steering is available in the ENA driver
+on platforms that support this feature.
+
 Management Interface
 --------------------
 
@@ -248,6 +252,28 @@ There is possibility that there won't be enough event file descriptors to
 handle both admin and Rx interrupts. In that situation the Rx interrupt request
 will fail.
 
+**Rx flow steering support**
+
+ENA PMD supports steering ingress packets to a specific Rx queue
+using the generic flow API (``rte_flow``).
+A rule matches IPv4 or IPv6 packets, optionally followed by TCP or UDP,
+on any combination of source and destination addresses,
+TOS (IPv4) or traffic class (IPv6), and source and destination ports.
+Each rule has a single ``QUEUE`` action.
+
+The following limitations apply:
+
+* Only ingress rules in group 0 with priority 0 are supported.
+* The ``ETH`` item is accepted only as a wildcard, without matching fields.
+* Rules can be created only after the device is started.
+* ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` is not advertised,
+  so the application must not rely on rules being kept across device stop,
+  and should flush them with ``rte_flow_flush()`` before stopping the device.
+* The queue index is checked only when the rule is created.
+  If the port is later reconfigured with fewer Rx queues,
+  the device silently drops the packets matching the rule.
+* The maximum number of rules is defined by the device.
+
 **Note about usage on \*.metal instances**
 
 On AWS, the metal instances are supporting IOMMU for both arm64 and x86_64 hosts.
doc/guides/nics/features/ena.ini +10 -0
index 037e0bad60..a8cbb6df1c 100644
@@ -22,3 +22,13 @@ Linux                = Y
 ARMv8                = Y
 x86-32               = Y
 x86-64               = Y
+
+[rte_flow items]
+eth                  = P
+ipv4                 = Y
+ipv6                 = Y
+tcp                  = Y
+udp                  = Y
+
+[rte_flow actions]
+queue                = Y
doc/guides/rel_notes/release_26_11.rst +4 -0
index 699f63d341..05281c3d11 100644
@@ -92,6 +92,10 @@ New Features
     ``xdp_meta_rx_ts_valid_mask``.
   * Added ``read_clock`` operation to query the PTP hardware clock.
 
+* **Updated Amazon ENA (Elastic Network Adapter) ethernet driver.**
+
+  * Added Rx flow steering support using the generic flow API.
+
 * **Updated Intel iavf driver.**
 
   * Runtime Rx/Tx queue setup is now automatically disabled
drivers/net/ena/base/ena_com.c +300 -0

312 lines not on this page · raw message

drivers/net/ena/base/ena_com.h +86 -0

110 lines not on this page · raw message

drivers/net/ena/base/ena_defs/ena_admin_defs.h +82 -1

119 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +70 -1

128 lines not on this page · raw message

drivers/net/ena/ena_ethdev.h +2 -1
index b204b07767..7a7d4a4036 100644
@@ -15,7 +15,7 @@
 #include <rte_timer.h>
 #include <rte_dev.h>
 #include <rte_net.h>
-
+#include "ena_flow.h"
 #include "ena_com.h"
 
 #define ENA_REGS_BAR	0
@@ -343,6 +343,7 @@ struct ena_adapter {
 	struct ena_stats_dev dev_stats;
 	struct ena_admin_basic_stats basic_stats;
 
+	uint16_t flow_rule_count;
 	u32 *indirect_table;
 	size_t indirect_table_size;
 
drivers/net/ena/ena_flow.c new file +542 -0

542 lines not on this page · raw message

drivers/net/ena/ena_flow.h new file +12 -0
new file mode 100644
index 0000000000..e83aa56e87
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Amazon.com, Inc. or its affiliates.
+ */
+#ifndef _ENA_FLOW_H_
+#define _ENA_FLOW_H_
+
+#include <rte_flow.h>
+
+/* Flow operations */
+extern const struct rte_flow_ops ena_flow_ops;
+
+#endif /* _ENA_FLOW_H_ */
drivers/net/ena/meson.build +1 -0
index 2b18d7add7..244775bf16 100644
@@ -10,6 +10,7 @@ endif
 sources = files(
         'ena_ethdev.c',
         'ena_rss.c',
+        'ena_flow.c',
         'base/ena_com.c',
         'base/ena_eth_com.c',
 )
Signature · 1 line
2.17.1