From patchwork Thu May 18 08:28:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran Kumar Kokkilagadda X-Patchwork-Id: 126978 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 866C642B39; Thu, 18 May 2023 10:28:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 765CE42B71; Thu, 18 May 2023 10:28:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6189340E25 for ; Thu, 18 May 2023 10:28:40 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I618o3001232; Thu, 18 May 2023 01:28:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=5n20BbL/8uPxtgP4II/MnLPteVqOBE8vhdYFkot8VJw=; b=bNu/10lvEalLbZX63c9mKjHt6EtxBffxYt48i9inJNZFQ0/qSTDEmM6F7lGCz5Ty3krN NdH90okaKpIUyzsn4LehpWenx4MaMBlGOvQuxU8iaSbZujd3dEGwc9plFG+eyc7nD5OO BXZy8FHBeUnViAOZvaj7+OaT3HL62oTV+3Ovi556CvVXNkE5wGRXKTAsSMvrAmNoAePv 08u5tU1XlgriFdLBZKotxx4o8qUdjQzM5V+Ru6igd3KAjBMOMSjvfjlqsOgrgIT58nf7 90yP8jA8TX+rfo2aOs1dZpY50aASO3U47qxdr79Ju2sZQ03vrEslwqeyHoCBOUsJg9km wg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexbc17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 01:28:38 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 01:28:36 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 01:28:36 -0700 Received: from cavium-DT31.. (unknown [10.28.36.159]) by maili.marvell.com (Postfix) with ESMTP id BFC143F70A5; Thu, 18 May 2023 01:28:33 -0700 (PDT) From: To: Ori Kam , Aman Singh , "Yuying Zhang" , Thomas Monjalon , "Ferruh Yigit" , Andrew Rybchenko CC: , Kiran Kumar K Subject: [PATCH v3] ethdev: add Tx queue flow matching item Date: Thu, 18 May 2023 13:58:30 +0530 Message-ID: <20230518082830.1730890-1-kirankumark@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Proofpoint-GUID: Mz4ceg2MxLOJnm5vLv3sxASZNZVjTLZO X-Proofpoint-ORIG-GUID: Mz4ceg2MxLOJnm5vLv3sxASZNZVjTLZO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_06,2023-05-17_02,2023-02-09_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kiran Kumar K Adding support for Tx queue flow matching item. This item is valid only for egress rules. An example use case would be that application can set different vlan insert rules with different PCP values based on Tx queue number. Signed-off-by: Kiran Kumar K Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 28 +++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 7 ++++++ doc/guides/rel_notes/release_23_07.rst | 5 ++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 26 +++++++++++++++++++ 6 files changed, 71 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 58939ec321..a68a6080a8 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -496,6 +496,8 @@ enum index { ITEM_QUOTA_STATE_NAME, ITEM_AGGR_AFFINITY, ITEM_AGGR_AFFINITY_VALUE, + ITEM_TX_QUEUE, + ITEM_TX_QUEUE_VALUE, /* Validate/create actions. */ ACTIONS, @@ -1452,6 +1454,7 @@ static const enum index next_item[] = { ITEM_METER, ITEM_QUOTA, ITEM_AGGR_AFFINITY, + ITEM_TX_QUEUE, END_SET, ZERO, }; @@ -1953,6 +1956,12 @@ static const enum index item_aggr_affinity[] = { ZERO, }; +static const enum index item_tx_queue[] = { + ITEM_TX_QUEUE_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -6945,6 +6954,22 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_item_aggr_affinity, affinity)), }, + [ITEM_TX_QUEUE] = { + .name = "tx_queue", + .help = "match on the tx queue of send packet", + .priv = PRIV_ITEM(TX_QUEUE, + sizeof(struct rte_flow_item_tx_queue)), + .next = NEXT(item_tx_queue), + .call = parse_vc, + }, + [ITEM_TX_QUEUE_VALUE] = { + .name = "tx_queue_value", + .help = "tx queue value", + .next = NEXT(item_tx_queue, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tx_queue, + tx_queue)), + }, }; /** Remove and return last entry from argument stack. */ @@ -11849,6 +11874,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY: mask = &rte_flow_item_aggr_affinity_mask; break; + case RTE_FLOW_ITEM_TYPE_TX_QUEUE: + mask = &rte_flow_item_tx_queue_mask; + break; default: break; } diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 32fc45516a..ac5c65131f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1486,6 +1486,13 @@ This item is meant to use the same structure as `Item: PORT_REPRESENTOR`_. See also `Action: REPRESENTED_PORT`_. +Item: ``TX_QUEUE`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Matches on the Tx queue of send packet . + +- ``tx_queue``: Tx queue. + Item: ``AGGR_AFFINITY`` ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index a9b1293689..bb04d99125 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= + * **Added flow matching of tx queue.** + + Added ``RTE_FLOW_ITEM_TYPE_TX_QUEUE`` rte_flow pattern to match tx queue of + send packet. + Removed Items ------------- diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 8f23847859..29f7dd4428 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3779,6 +3779,10 @@ This section lists supported pattern items and their attributes, if any. - ``affinity {value}``: aggregated port (starts from 1). +- ``tx_queue``: match tx queue of send packet. + + - ``tx_queue {value}``: send queue value (starts from 0). + - ``send_to_kernel``: send packets to kernel. diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 69e6e749f7..f0d7f868fa 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -164,6 +164,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext)), MK_FLOW_ITEM(QUOTA, sizeof(struct rte_flow_item_quota)), MK_FLOW_ITEM(AGGR_AFFINITY, sizeof(struct rte_flow_item_aggr_affinity)), + MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 713ba8b65c..fe28ba0a82 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -672,8 +672,34 @@ enum rte_flow_item_type { * @see struct rte_flow_item_aggr_affinity. */ RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY, + /** + * Match Tx queue number. + * This is valid only for egress rules. + * + * @see struct rte_flow_item_tx_queue + */ + RTE_FLOW_ITEM_TYPE_TX_QUEUE, }; +/** + * RTE_FLOW_ITEM_TYPE_TX_QUEUE + * + * Tx queue number + * + * @see struct rte_flow_item_tx_queue + */ +struct rte_flow_item_tx_queue { + /** Tx queue number that packet is being transmitted */ + uint16_t tx_queue; +}; + +/** Default mask for RTE_FLOW_ITEM_TX_QUEUE. */ +#ifndef __cplusplus +static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = { + .tx_queue = RTE_BE16(0xffff), +}; +#endif + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice.