From patchwork Mon Oct 9 16:24:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 132438 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 B1BBC4233F; Mon, 9 Oct 2023 18:25:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F7584068E; Mon, 9 Oct 2023 18:25:10 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by mails.dpdk.org (Postfix) with ESMTP id F1799402A3 for ; Mon, 9 Oct 2023 18:25:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HdFG4nn7og1GzsJxS+xPNZA8zenXRwLhcbIpmwI//X4h/ER5EW4DqEcF/jj2jtzU5ubKAm2ah8sDYQCpw7KccvG1RCnDDt7u1Qpvq+263kQYVt5041REu79VYVolKjNXK5JITWao7p1c2kDizOGYn3/rNB+mWn4dMeRI7sBq5gvROr8g3szDuu+9PvwRVQGpdut3+hrG48Vf+Fe3ksketYZwMVVfn0kuJMF23gMdVcIT3vKOkn3eMNR8fx6p83h+KRulgHcbvTqAaajCWI7+Nm2fZ5/V1+pDcTUk2eWKCtyPZLSPPnWA8lmZYiBnF7e8Pi5Xbg1oBuSqs8fL0uciUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XWdIqdHchV6YNoq0VsN63qxHAnVY3EADl16h06S5FSE=; b=XQE/PvbgibpLe+atYmu3m0JJA6/xLJcXZu4a+/yiZOxHIIXVI9WtzYd3K0N/IwyTGKhd69rvtiwhTgSxv+vLSCesGEbRaSI3cEBZ0+rNP25qIUmINE6foWDqwqeXk5bjPYuSEv19pIvoiSeyyQdOTCfKFAgYUj2xvbKpB6TZz8TBlXvD1KAgfzWyABDwbTKpKtRVf83aeABKDtjpyKKX5Eykkr/jWgBm8em4M0+uMRVtDgAYNaYgzkEHJjwG7CaCRj4HuEm9kDvVcKqXL6Jsomk/dcEGM1LCBmlEh3ubpKGbIeMn0Ol+4nM8UL74OMjUvcExIbuJSKqbqbzZW/DPXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XWdIqdHchV6YNoq0VsN63qxHAnVY3EADl16h06S5FSE=; b=dkojhNhQ/uJZtxC/fi0RdljWagqlSxK4RQO0Ns4iWTVhOVFbc2lHDfg9VxZaoYMVR7qMlS1T/KTg0iVxLEH2b0VLFde+YuGdDQ1XfKp0He/j554LOGMHlOTsHJo3eJ6AOmCluBX3AZm37CNU5Ka0kBB+HQmGUBTgA9IEZVTnoiUuy6hvYNlp5S5Du0hywb3nMBUdoKfQ+1hxTkYtg6yGcUK23EJpIGme3JWHsfeiccCIcpsmyy725ZuYyvFSXzDbLHkxSKlvpj3dSlwEAo3D9OwuqefLEJkugx2fb3br76JiFnjj4dmH/RlyJdJpu9vNHf1UsauWoT20QZL+D5Zi/Q== Received: from CY5PR15CA0079.namprd15.prod.outlook.com (2603:10b6:930:18::15) by SA1PR12MB8120.namprd12.prod.outlook.com (2603:10b6:806:331::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.38; Mon, 9 Oct 2023 16:25:06 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:930:18:cafe::d8) by CY5PR15CA0079.outlook.office365.com (2603:10b6:930:18::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36 via Frontend Transport; Mon, 9 Oct 2023 16:25:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 9 Oct 2023 16:25:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 09:25:00 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 09:24:58 -0700 From: Alexander Kozyrev To: CC: , , , , Subject: [PATCH v3] ethdev: add packet type matching item Date: Mon, 9 Oct 2023 19:24:44 +0300 Message-ID: <20231009162444.3998178-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20231009160850.3997269-1-akozyrev@nvidia.com> References: <20231009160850.3997269-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|SA1PR12MB8120:EE_ X-MS-Office365-Filtering-Correlation-Id: bc26358b-d330-4d28-4c84-08dbc8e44ca8 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: spGrHkkq2HIMoaIfYhNRHJ5HitecW6vjp/PfLM5mZdUamthgTM1gFAwYAHwGqLN46IlKm9TfAUQtXlaBoA4Xmdj9CzBxbe7Wx6iFXlZVKqguk/Ga0R5pHWdB2/ctuTdFR6nXbhFBQ3mGiOyuYWTPNpb1wGonaaMcb9IzWWwYaBpAIzdlTCW7ZQOpJxZyH+IPBy7y5x1PVBLLbP8iSzIXfho7d7I5v9cSNE7xY8GLMKHKi0W7EsSGsEI11rDzYID8+XpZCnm1c8cDfY6lxpi5p+xBMTO87XNtw2EIT2gQWjKUxqDRV3oOt3oHDFBMYh09CxKJM/xuHE4B1Vby6flKYhrY0XSZIXyoeE+Ds6MoMos/h2CwxnF49bkoT2JEkWa7MBYUkpcISM2Wo3SON1jtilChvCvc4Tz+gEbbbiLt5CyIghrQ+YlZrHyGislzq8jnvNIy0mUhOZselj01Yda2LIcAOv7yrEqembAPpW9RUJOga7iohacHsvGyJXoTfuqUEms0R1cFv7hE4JPX60rMfyjXLpcT2hXTh+bpfDP0I4IZ/A1htK+a/ckd3on0rxWew4tHwcq5qqjIs8eisUts27pwqB87BrTe5o8eUwBuf/ZmphaoAe8cqA+9WbxLHp2i5eSfTV6jngvcthjjpmOccFCq6DQN1RxlxAupUgDheZYjyU3tIIsQFTbhhteLT+dlLf6993cKCxhJ9AZOFvkNX8Bztc1AcEKFcCzPfw1cW10= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(230922051799003)(1800799009)(186009)(82310400011)(451199024)(64100799003)(40470700004)(36840700001)(46966006)(40460700003)(82740400003)(2616005)(83380400001)(5660300002)(4326008)(47076005)(54906003)(6916009)(70586007)(6666004)(1076003)(16526019)(316002)(26005)(478600001)(70206006)(8936002)(426003)(336012)(41300700001)(86362001)(2906002)(356005)(7636003)(40480700001)(36756003)(36860700001)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 16:25:06.6160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc26358b-d330-4d28-4c84-08dbc8e44ca8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8120 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 Add RTE_FLOW_ITEM_TYPE_PTYPE to allow matching on L2/L3/L4 and tunnel information as defined in mbuf. To match on RTE_PTYPE_L4_TCP and RTE_PTYPE_INNER_L4_UDP: flow pattern_template 0 create pattern_template_id 1 ingress template ptype packet_type mask 0x0f000f00 / end flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 pattern ptype packet_type is 0x02000100 / end actions queue index 1 / end Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 28 +++++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 ++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 25 ++++++++++++++++++ 6 files changed, 66 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2b1d9b70ee..02874c4597 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -534,6 +534,8 @@ enum index { ITEM_IB_BTH_PSN, ITEM_IPV6_PUSH_REMOVE_EXT, ITEM_IPV6_PUSH_REMOVE_EXT_TYPE, + ITEM_PTYPE, + ITEM_PTYPE_VALUE, /* Validate/create actions. */ ACTIONS, @@ -1579,6 +1581,7 @@ static const enum index next_item[] = { ITEM_AGGR_AFFINITY, ITEM_TX_QUEUE, ITEM_IB_BTH, + ITEM_PTYPE, END_SET, ZERO, }; @@ -2099,6 +2102,12 @@ static const enum index item_ib_bth[] = { ZERO, }; +static const enum index item_ptype[] = { + ITEM_PTYPE_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -5906,6 +5915,22 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth, hdr.psn)), }, + [ITEM_PTYPE] = { + .name = "ptype", + .help = "match L2/L3/L4 and tunnel information", + .priv = PRIV_ITEM(PTYPE, + sizeof(struct rte_flow_item_ptype)), + .next = NEXT(item_ptype), + .call = parse_vc, + }, + [ITEM_PTYPE_VALUE] = { + .name = "packet_type", + .help = "packet type as defined in rte_mbuf_ptype", + .next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)), + }, + /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -12820,6 +12845,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_IB_BTH: mask = &rte_flow_item_ib_bth_mask; break; + case RTE_FLOW_ITEM_TYPE_PTYPE: + mask = &rte_flow_item_ptype_mask; + break; default: break; } diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 2011e97127..e41a97b3bb 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -137,6 +137,7 @@ ppp = pppoed = pppoes = pppoe_proto_id = +ptype = quota = raw = represented_port = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 860e42025f..b65b25d443 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1566,6 +1566,13 @@ Matches an InfiniBand base transport header in RoCE packet. - ``hdr``: InfiniBand base transport header definition (``rte_ib.h``). +Item: ``PTYPE`` +^^^^^^^^^^^^^^^ + +Matches the packet type as defined in rte_mbuf_ptype. + +- ``packet_type``: L2/L3/L4 and tunnel information. + Actions ~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index e6d218caaa..07bac9a311 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3808,6 +3808,10 @@ This section lists supported pattern items and their attributes, if any. - ``send_to_kernel``: send packets to kernel. +- ``ptype``: match the packet type (L2/L3/L4 and tunnel information). + + - ``packet_type {unsigned}``: packet type. + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index c9d23da702..ba8bf27090 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(AGGR_AFFINITY, sizeof(struct rte_flow_item_aggr_affinity)), MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)), MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)), + MK_FLOW_ITEM(PTYPE, sizeof(struct rte_flow_item_ptype)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index e576b15e3d..b79bb9968b 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -694,6 +694,14 @@ enum rte_flow_item_type { * @see struct rte_flow_item_ib_bth. */ RTE_FLOW_ITEM_TYPE_IB_BTH, + + /** + * Matches the packet type as defined in rte_mbuf_ptype. + * + * See struct rte_flow_item_ptype. + * + */ + RTE_FLOW_ITEM_TYPE_PTYPE, }; /** @@ -2309,6 +2317,23 @@ static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = { }; #endif +/** + * + * RTE_FLOW_ITEM_TYPE_PTYPE + * + * Matches the packet type as defined in rte_mbuf_ptype. + */ +struct rte_flow_item_ptype { + uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PTYPE. */ +#ifndef __cplusplus +static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { + .packet_type = 0xffffffff, +}; +#endif + /** * Action types. *