From patchwork Sun Sep 13 15:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bing Zhao X-Patchwork-Id: 77544 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2E3C7A04C9; Sun, 13 Sep 2020 17:49:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0C2811C012; Sun, 13 Sep 2020 17:49:26 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 8A87EE07 for ; Sun, 13 Sep 2020 17:49:24 +0200 (CEST) From: Bing Zhao To: thomas@monjalon.net, orika@nvidia.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org Date: Sun, 13 Sep 2020 23:48:57 +0800 Message-Id: <1600012140-70151-2-git-send-email-bingz@nvidia.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1600012140-70151-1-git-send-email-bingz@nvidia.com> References: <1600012140-70151-1-git-send-email-bingz@nvidia.com> Subject: [dpdk-dev] [RFC PATCH v2 1/4] ethdev: add support for flow item transmit queue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) 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