[RFC,v2,1/4] ethdev: add support for flow item transmit queue

Message ID 1600012140-70151-2-git-send-email-bingz@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series introduce support for hairpin between two ports |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bing Zhao Sept. 13, 2020, 3:48 p.m. UTC
  New rte_flow_item_tx_queue is introduced to support matching on the
traffic from a specific transmit queue. This is only for the egress
direction. For ingress, the receive queue index will be part of the
actions with ACTION QUEUE or RSS and there is no needs to match.

By adding this flow item, it will be easy for the application to
create some wildcard rules to distribute the egress traffic for the
further handling.

Normally, all the traffic from software to wire will have the same
wildcard rule. If the packets need to be handled in different ways,
packets' headers and metadata, etc. will be used for matching.

But in some cases, for example:
1. Packets from different TX queues will have different next common
   behaviors.
2. Hairpin TX traffic should have different behavior from software
   egress traffic.
Matching on the TX queue will help to reduce the rules number and
simplify the rules management.

The support for this new item will be decided by the PMD driver and
the capacity of the NIC.

Signed-off-by: Bing Zhao <bingz@nvidia.com>
---
 lib/librte_ethdev/rte_flow.c |  1 +
 lib/librte_ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
  

Patch

diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index f8fdd68..4600e27 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -96,6 +96,7 @@  static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV3OIP, sizeof(struct rte_flow_item_l2tpv3oip)),
 	MK_FLOW_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
 	MK_FLOW_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
+	MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)),
 };
 
 /** Generate flow_action[] entry. */
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index da8bfa5..264755a 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -537,6 +537,13 @@  enum rte_flow_item_type {
 	 */
 	RTE_FLOW_ITEM_TYPE_ECPRI,
 
+	/**
+	 * Matches TX queue ID of a specific port for egress traffic.
+	 *
+	 * See struct rte_flow_item_tx_queue.
+	 */
+	RTE_FLOW_ITEM_TYPE_TX_QUEUE,
+
 };
 
 /**
@@ -1580,6 +1587,29 @@  static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
 #endif
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_TX_QUEUE
+ *
+ * Match egress traffic originating from a TX queue of a port. Port refers to
+ * a struct rte_eth_dev object on the application side and the transmit queue
+ * index must be in the range [0, nb_tx_queue - 1] previously supplied to
+ * rte_eth_dev_configure(). Normally only supported if the TX queue ID is known
+ * by the underlying PMD.
+ */
+struct rte_flow_item_tx_queue {
+	uint32_t queue; /**< DPDK TX queue ID of a specific port. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_TX_QUEUE. */
+#ifndef __cplusplus
+static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = {
+	.queue = 0xffffffff,
+};
+#endif
+
+/**
  * Matching pattern item definition.
  *
  * A pattern is formed by stacking items starting from the lowest protocol