From patchwork Mon Sep 26 14:57:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116892 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 B9ED0A00C2; Mon, 26 Sep 2022 16:58:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2823A42B6E; Mon, 26 Sep 2022 16:58:39 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2066.outbound.protection.outlook.com [40.107.212.66]) by mails.dpdk.org (Postfix) with ESMTP id DDA1C42B76 for ; Mon, 26 Sep 2022 16:58:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9TGpcHbMiM6KzEEhQxZ+ch/ZJMLgxXgV6HUcJExEP/Vngm7db+y9Q3Nrb6MYXHnfqkClOi9Sxa81cOkl0CkkA4FyACIP7+oNJSgo5fCwnfXDDDLeajWiJXr+wEvDZ6zpErbfNBjQnY1G0yfOliUJRofOtzKodTOHxaWndsgU17bbYSMc4pKJOcMzceYx/+BMTao5eiiVGOlhZtSBsyw+WBIzvohOmR4oRAnMBHjgyZYSINTGOT0a3U3UzNEWZOvsrsUOCwpU2/jUn1lXq4YLTS7rClWpEeZ3hyEYNqajXCkZvd2iXLcXXtZt1ezmlVx9Nu1vx6tLoJv2nDU9fSK+Q== 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=ASmnbmXf5pN7G6ArcinnpguqadBZz7mozLymfu0IYQc=; b=d15PEG5sjz0FZ2n140kVytYXdcx8T/a8kwWG9npOnx1eUDOrFI/QOmT26WIuEvwkGW0Uj+zW/Dn8urGxwFYsgG/2+hNeHFnyvu2UlijM9wXfxkZqoOo9K5cKF7NpKhsWwNVo4DdQ/eoMdVe2AS5PZSlBVRvXQtoDCoSgfAfYTUhxc7lFkrOYhTiE2uNXC3Y6NR/J9Hyshc2hduRJMfNCVkiHPrlegKlyFENa6sIesrYbzi71du7RtaCtXlYZSOjxYLNdEpWUQ+LGpwNnnZVIdAb1hYbYmVYpH5NKgHlkSdH3U0eFWslXGJG77NIA7sFmGCcxFNVd5NqwCAYD2pB6oQ== 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=ASmnbmXf5pN7G6ArcinnpguqadBZz7mozLymfu0IYQc=; b=cSzq8cJs+2EuepNwzdIh++li5jgl4AX+JRAx+pP0NlkLqQTTOFOEq4CznKDyFv1iwUsFLkQkf0POTIsESVAeyPKYQ9u/5Z3fLK9Kv17ymfXqGHbu4mi46TPVDdKo69q/Jv5VpvpVU/camP3oCsG3SxZGvV9RzLCia/pn1wGjY4WpMwuzEZsujvA9fNRnw4YxAhN6LVOEiAxVfz3SPwC2Z6R3p+FdLrCcHemV+Zu0qnUyZX8V9paK+GpcgQYT6nz/S/ZIATxPOd6jnFjDBOduDXiVN57zB+Lz3f6fsPvnlIqXvWnM77DlHj0QTVO2MgamoVf1kQej9kXvuRFI6Augug== Received: from DS7PR05CA0046.namprd05.prod.outlook.com (2603:10b6:8:2f::14) by CY8PR12MB7435.namprd12.prod.outlook.com (2603:10b6:930:51::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:35 +0000 Received: from DM6NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::fc) by DS7PR05CA0046.outlook.office365.com (2603:10b6:8:2f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.9 via Frontend Transport; Mon, 26 Sep 2022 14:58:35 +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 DM6NAM11FT106.mail.protection.outlook.com (10.13.172.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:35 +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.26; Mon, 26 Sep 2022 07:58:28 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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.29; Mon, 26 Sep 2022 07:58:24 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 4/7] ethdev: add meter color mark flow action Date: Mon, 26 Sep 2022 17:57:42 +0300 Message-ID: <20220926145745.3962600-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT106:EE_|CY8PR12MB7435:EE_ X-MS-Office365-Filtering-Correlation-Id: 4157be89-1077-46b8-132b-08da9fcf9627 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: PvFT9ltiu4uIa5OJZIWy//pI4o1cX6WkQSIfu9pIxrLx1RrbEowExtBaM1QH/8cy4Y/EKYssDWkhtF7+tHDE0bNSWXyzQnHEY/gQkCFHs1+j5kurAqPGdXE+6uoBlAvdOBe+bfu1xG4T8rwrXHRt7PYCzqXhynNS3FXFekixN4/GfoumdQ309aY/r51I0KAY7J0Bu/QJc6f5D/Kl2EQKn6x0Uj7ilrEk+FR/b1fgXOUxRJRv0vUEDJ4H5HyJN97hiY0S7o9FxaUuzBZd6Tp770H67eK1gNL/tVnE4Pbt1aUKpEmVieAG/8JBIPICDthMaHmYdVNG2qNuXkHpJ6FcB/tYaaTy7rrr6dYSni1CPiaaoaDLSe7hvjPdLONFZJ0n61GTXYqeLWPA0lnU2cCu8TJVEfPu0Ql+n3/J7iJyZRK2qg+fp3hUjrN191V5+snvRMR6fhtPldpggjR7nMh+9xw0KWvFB8f7/OlAXU4ZyqBGRaW002EyH4xV0uxVPYVV/RDlKI1kaoSwG6HcEjGwLyr1fXoOxuJvKvhOebdNj1Fy3sFmhb309o8ABcv94R7f494S0vV/B2gr1IMA/qHOPEd3dp+OdtskVuJ/Vw030UDpB31BIoSslZJTzThlvbHqU0UWN+OtPQjnnubrK3Jg2CUOFOPmKKVKzwHRRFraNIyVbSp3HLB3obwjU0ZBRmI3yYi//aNTo6QOOWsaKGOMI4cnMna1WIvnaUMr2bWSZzakMqYiDtEsWCvy+AhbT38fQHht7iW/Yjx25JMFV2DVuQ== 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:(13230022)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199015)(36840700001)(46966006)(40470700004)(54906003)(26005)(5660300002)(478600001)(316002)(6916009)(70206006)(70586007)(6666004)(8936002)(41300700001)(7416002)(2906002)(426003)(1076003)(83380400001)(40460700003)(36860700001)(47076005)(336012)(186003)(16526019)(36756003)(86362001)(40480700001)(4326008)(8676002)(82310400005)(82740400003)(2616005)(7636003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:35.1130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4157be89-1077-46b8-132b-08da9fcf9627 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: DM6NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7435 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 Create a new Flow API action: METER_MARK. It Meters a packet stream and marks its packets with colors. The marking is done on a metadata, not on a packet field. Unlike the METER action, it performs no policing at all. A user has the flexibility to create any policies with the help of the METER_COLOR item later, only meter profile is mandatory here. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 25 ++++++++++++ doc/guides/rel_notes/release_22_11.rst | 1 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 56 ++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 018def1033..5b87d9f61e 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3411,6 +3411,31 @@ This action is meant to use the same structure as `Action: PORT_REPRESENTOR`_. See also `Item: REPRESENTED_PORT`_. +Action: ``METER_MARK`` +^^^^^^^^^^^^^^^^^^^^^^ + +Meters a packet stream and marks its packets with colors. + +Unlike the ``METER`` action, policing is optional and may be +performed later with the help of the ``METER_COLOR`` item. +The profile and/or policy objects have to be created +using the rte_mtr_profile_add()/rte_mtr_policy_add() API. +Pointers to these objects are used as action parameters +and need to be retrieved using the rte_mtr_profile_get() API +and rte_mtr_policy_get() API respectively. + +.. _table_rte_flow_action_meter_mark: + +.. table:: METER_MARK + + +------------------+----------------------+ + | Field | Value | + +==================+======================+ + | ``profile`` | Meter profile object | + +------------------+----------------------+ + | ``policy`` | Meter policy object | + +------------------+----------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 47925ef005..375af892ac 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -60,6 +60,7 @@ New Features * Added METER_COLOR item to match Color Marker set by a Meter. * Added ability to set Color Marker via modify_field Flow API. * Added Meter API to get a pointer to profile/policy by their ID. + * Added METER_MARK action for Metering with lockless profile/policy access. * **Updated Wangxun ngbe driver.** diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 99247b599d..7ff024f33e 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -260,6 +260,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)), MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)), + MK_FLOW_ACTION(METER_MARK, sizeof(struct rte_flow_action_meter_mark)), }; int diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 906c28807a..4531d2f7c5 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -2903,6 +2903,14 @@ enum rte_flow_action_type { * @see struct rte_flow_action_ethdev */ RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT, + + /** + * Traffic metering and marking (MTR). + * + * @see struct rte_flow_action_meter_mark + * See file rte_mtr.h for MTR profile object configuration. + */ + RTE_FLOW_ACTION_TYPE_METER_MARK, }; /** @@ -3774,6 +3782,54 @@ struct rte_flow_action_modify_field { uint32_t width; /**< Number of bits to use from a source field. */ }; +/** + * RTE_FLOW_ACTION_TYPE_METER_MARK + * + * Traffic metering and marking (MTR). + * + * Meters a packet stream and marks its packets either + * green, yellow, or red according to the specified profile. + * The policy is optional and may be specified for defining + * subsequent actions based on a color assigned by MTR. + * Alternatively, the METER_COLOR item may be used for this. + */ +struct rte_flow_action_meter_mark { + + /**< Profile config retrieved with rte_mtr_profile_get(). */ + struct rte_flow_meter_profile *profile; + /**< Policy config retrieved with rte_mtr_policy_get(). */ + struct rte_flow_meter_policy *policy; + /** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */ + int color_mode; + /** Initial Color applied to packets in Color-Aware mode. */ + enum rte_color init_color; + /** Metering state: 0 - Disabled, 1 - Enabled. */ + int state; +}; + +/** + * RTE_FLOW_ACTION_TYPE_METER_MARK + * + * Wrapper structure for the context update interface. + * + */ +struct rte_flow_update_meter_mark { + /** New meter_mark parameters to be updated. */ + struct rte_flow_action_meter_mark meter_mark; + /** The profile will be updated. */ + uint32_t profile_valid:1; + /** The policy will be updated. */ + uint32_t policy_valid:1; + /** The color mode will be updated. */ + uint32_t color_mode_valid:1; + /** The initial color will be updated. */ + uint32_t init_color_valid:1; + /** The meter state will be updated. */ + uint32_t state_valid:1; + /** Reserved bits for the future usage. */ + uint32_t reserved:27; +}; + /* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;