From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FB68436EE; Thu, 14 Dec 2023 11:59:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DF7E42FFD; Thu, 14 Dec 2023 11:59:06 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.49]) by mails.dpdk.org (Postfix) with ESMTP id B2C6E40697 for ; Thu, 14 Dec 2023 11:59:05 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MEG+xMY5EcI7MN1iL+SrrpXvtw0Euh7oLBAAhcDLf1MVOElmw+zeY6Kn9QoBi7Q1nE0q7pedTqelvy7IgODKFqWGnnPxUu+bRxOguRud76wvuTl3DXynU0sAVow9VxNLF41qnpeaE4Djj4zV/tceEgurYuNjpczYfwHFXrpTPEtUkLV6oSsmXWaYJDpczn+a1ov+RiX5wNY3bkZdKBvLmb2KjtmobsCPT5tEKY3oo9XUe7TuAE/pdFUO5EoKGPj86ZqwMyNKbca4pIPuetYQQ0nUrhmOJnO0zP9aWT6Pg9hSs2q332Ct00ijQXaIsVUf4nf95IDuUjc+csL5B04Rxg== 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=Cs8rvg3tEZGOT6r7vrpZ+CHbUEtlmuQkW5aGVs4wlq0=; b=iv+ZiCiuWuWyN8hEIMEsaUDMYimPeFP5/OI7pHpeyy7dOPSEEvQVJ4SiqO/TYI3WUecGwpHVzYR3z2Z0p27Sq5Q/PD4gFBboJeWsts17GjCp/s09kKpxkp+OoDN1AstaD/gBWglC4fzr2FduveEQ/h6fAkeag00Bh8AgtMlbW30HntWYZhFF5GVyaAD3/S1p/TFEflm6ojK7GM4299BHNx2Hz0rBv1Lg/qSnfOBdXWi+a8g0kWfrWTKSIBiaIW/4xJZFzJ0NOa/+pc1zfj+eZzd4NtWZs0BbA78sIavk7HvyxZOGLbnedh4yjAHdX7bDQ09FInn5zX8/npHG9JOCmQ== 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 (0) 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=Cs8rvg3tEZGOT6r7vrpZ+CHbUEtlmuQkW5aGVs4wlq0=; b=ASzKYWUxN1szMQEcNrDKN4GehNHSdI9ymmgCitRvINcSHdyXVS9TPOYJqipdr10CgSpXZYCxSmGpTV6a6YqZ+BseoT7TrMwlOlXZxtWulfgWyf26dBbASUB+t3OMdr9ytlVUhxqb6rnWoLJ6aLvd//ft4jJzXshKKnaH8jOQ2BeQRA7sbfykZGwOmZbB3fbr+bL9JIvgfeNPp4Qf/P9FAbLz7jO65GuhOoa7A//CQx2lhc6fcb3Nl5x0N4tBrwggFS+uMS5B3wogDP8x2eC7q0CkmNx3wt7CC+elv3pmKxn7T8jfHHzmNT0oNCkuXQYSKjn8SwIRlSylUcgwuA8gag== Received: from DM6PR07CA0062.namprd07.prod.outlook.com (2603:10b6:5:74::39) by LV2PR12MB5847.namprd12.prod.outlook.com (2603:10b6:408:174::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Thu, 14 Dec 2023 10:59:03 +0000 Received: from DS2PEPF0000343C.namprd02.prod.outlook.com (2603:10b6:5:74:cafe::e9) by DM6PR07CA0062.outlook.office365.com (2603:10b6:5:74::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33 via Frontend Transport; Thu, 14 Dec 2023 10:59:03 +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 DS2PEPF0000343C.mail.protection.outlook.com (10.167.18.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Thu, 14 Dec 2023 10:59:03 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Thu, 14 Dec 2023 02:58:54 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 14 Dec 2023 02:58:53 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Thu, 14 Dec 2023 02:58:51 -0800 From: Michael Baum To: CC: Ori Kam , Dariusz Sosnowski , Aman Singh , Yuying Zhang , Ferruh Yigit , "Thomas Monjalon" Subject: [PATCH v4 1/2] ethdev: add random item support Date: Thu, 14 Dec 2023 12:58:43 +0200 Message-ID: <20231214105844.1640764-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214105844.1640764-1-michaelba@nvidia.com> References: <20231130163215.666239-1-michaelba@nvidia.com> <20231214105844.1640764-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343C:EE_|LV2PR12MB5847:EE_ X-MS-Office365-Filtering-Correlation-Id: ebaa15c3-3d4f-46b1-66c1-08dbfc93af24 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: wUvS2LGWKBhJ58FHa9DwRJQa7BawYYBK+y3wHfNyZ1JAwNmlj5oBPItn/HU8Ww+J2GG8zawW4NpMrLmE4ob3wlkuM8MgJG5dfTeY40lGn5umUwwXu9ZEYYCV/U6Gtg0OLesHbmJ9Xdm4u0P8JgT6WA3WWOGxJTGWdBqQkzshn6wiU0HC19f8DBx+jpHIg5tvcP6yjhfl6cFPhsCXkAwAIGzBm16ZEX3JpMS9NR7j91xAS1+JL7YPUkRISDsy9vROasMgx/5cXh8btjtQPBPT8f9jgjtVQD++3dcvab9lIhO5d9ge8UABTs+YsM4HhXk0BX7JI4lX0vpIYyBxQm6tc1igQ4PoI3Xjx+8IBioxAT+JlpLSmCLx4pUV5ech8XGbsbVsfQ/OlOVZ23OPhrL/bPf/QtnNqjoDDLgQ5EzZ/FTnB/QFxnOP0CWN5SWTWpY30mBAruCxXBK7VT74wd8QawnBosSyYjKl+8sOzd0P5crPDyBm7N3i6Kn4xhmWg4jig+c8Fd3JwHqbg3VyrIEac0ifljTjEcUHjNA5M6WwmOLV3BD72COZfuv7nFhoGnbdWPRI+qzzt7iy0CMI7mGZRDXU0xG0WTvfNDxhd5qrhhtxR0gS0D+56tJ0AyFeqqpromII/QjWojKT51CgMrnxijroKBVnD48AG5iqUW36VjnASq+zXro/NbK0kFN9TM4epsV8CIvb9Z+Zc3mLVwRqah6z94s4FagL4V3pyBqTrvXlIv+7Fx+iyiGO+g95NIXHXGgSKfjMrxsQSR4jOXU48Q== 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)(39860400002)(136003)(346002)(376002)(396003)(230273577357003)(230173577357003)(230922051799003)(64100799003)(186009)(1800799012)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(55016003)(40480700001)(1076003)(2616005)(6286002)(426003)(336012)(26005)(7696005)(6666004)(40460700003)(82740400003)(86362001)(36756003)(7636003)(356005)(5660300002)(8936002)(8676002)(4326008)(36860700001)(83380400001)(47076005)(54906003)(70206006)(6916009)(70586007)(41300700001)(2906002)(316002)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2023 10:59:03.0441 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebaa15c3-3d4f-46b1-66c1-08dbfc93af24 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: DS2PEPF0000343C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5847 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 support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM". This item enables to match on some random value as a part of flow rule. Signed-off-by: Michael Baum --- doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 14 +++++++++++ doc/guides/rel_notes/release_24_03.rst | 5 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 35 +++++++++++++++++++++++++- 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 806cb033ff..6d50236292 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -140,6 +140,7 @@ pppoe_proto_id = ptype = quota = raw = +random = represented_port = sctp = tag = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 627b845bfb..900fdaefb6 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1573,6 +1573,20 @@ Matches the packet type as defined in rte_mbuf_ptype. - ``packet_type``: L2/L3/L4 and tunnel information. +Item: ``RANDOM`` +^^^^^^^^^^^^^^^^ + +Matches a random value. + +A random unsigned integer (at most 32-bit) is generated for each packet during +flow rule processing, by either HW, SW or some external source. +Application can match on either exact value or range of values. +This value is not based on the packet data/headers. +Application shouldn't assume that this value is kept during the lifetime of +the packet. + +- ``value``: Specific value to match. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 6f8ad27808..819cef7f20 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added flow matching of random value.** + + * Added ``RTE_FLOW_ITEM_TYPE_RANDOM`` to match random value. + * Added ``RTE_FLOW_FIELD_RANDOM`` to represent it in field API. + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 549e329558..090b936ca9 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -136,6 +136,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)), MK_FLOW_ITEM(MARK, sizeof(struct rte_flow_item_mark)), MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)), + MK_FLOW_ITEM(RANDOM, sizeof(struct rte_flow_item_random)), MK_FLOW_ITEM(TAG, sizeof(struct rte_flow_item_tag)), MK_FLOW_ITEM(GRE_KEY, sizeof(rte_be32_t)), MK_FLOW_ITEM(GRE_OPTION, sizeof(struct rte_flow_item_gre_opt)), diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index affdc8121b..860b100e45 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -704,6 +704,19 @@ enum rte_flow_item_type { * */ RTE_FLOW_ITEM_TYPE_PTYPE, + + /** + * [META] + * + * Matches a random value. + * + * This value is not based on the packet data/headers. + * Application shouldn't assume that this value is kept during the + * lifetime of the packet. + * + * @see struct rte_flow_item_random. + */ + RTE_FLOW_ITEM_TYPE_RANDOM, }; /** @@ -2047,6 +2060,25 @@ static const struct rte_flow_item_ib_bth rte_flow_item_ib_bth_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_RANDOM + * + * Matches a random value. + */ +struct rte_flow_item_random { + uint32_t value; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_RANDOM. */ +#ifndef __cplusplus +static const struct rte_flow_item_random rte_flow_item_random_mask = { + .value = UINT32_MAX, +}; +#endif + /** * Matching pattern item definition. * @@ -3903,7 +3935,8 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */ RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */ RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */ - RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */ + RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN,/**< IPv6 payload length. */ + RTE_FLOW_FIELD_RANDOM /**< Random value. */ }; /** -- 2.25.1