From patchwork Wed Jun 1 03:44:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112169 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 39DF3A0552; Wed, 1 Jun 2022 05:44:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D288F40A84; Wed, 1 Jun 2022 05:44:31 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2080.outbound.protection.outlook.com [40.107.92.80]) by mails.dpdk.org (Postfix) with ESMTP id 5561F40150 for ; Wed, 1 Jun 2022 05:44:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LybUzQCb6dMe9muJQsKQ6l9gQPZCM8CetPJWwp7nWPRUopLOqtVQm7LUk2xPPzGAspHTIaDozTouJaGPxDm7XRb11oF4atnisQ6CeSRxRw8RRo3CfXFgl9q+H10cupvnaKc1hcxxDqTGNGFpo2FzfsDR0Na5P7PdtchfV8UB1jaR1Ve2vLq8538+c6MJbvlvBwLKlj1NeiYo+dmxdOfjtWpBX7FAH3lSQ/zEiwgkCTBnpXDMy/opc+9gPJLn9dQ1spUeaeOpKjFyr4+JpWd3cvZpwVVZLAToJNpUJq8y+MGepIU0uaDYhA1262/yXMxLoDIY5Ctbf/O2D/WfSAYhJQ== 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=066KMp7W2DFWc5+HcV9RDmOGcPMC/HcCjL/Lv9VyK5Y=; b=RmEWNhfPS06F6SzESFUnWYXPIe63EG6y40g5WJCMA0ZL4qvfWMe/EW/pJ5YMe2eXlbRVEtzfuldppPfHlN1+IjPceHWDnKp5v/0GB5FEOmBMQIPT+LQNoB9AHkk09CzZu+n+EqAHpO398ce4nE+hC0UcljcApW7vR+xOwA9RdCZGLbm2u5nSe4v7xYrfiulWuzTpQ5QT/V2AHwHk0/elz3JW3NgdQQFK1pxGKm1T7yU1QYhRjaF+vSYA3FliLGdVOWBC7qHgQAzllTowGyPINTfmZdb0gZZXU2frPGbW314LSeyDC+1Hs9bTXv/NIw78y79dCavV++vtPqcj7e5mZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=intel.com 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=066KMp7W2DFWc5+HcV9RDmOGcPMC/HcCjL/Lv9VyK5Y=; b=kZGkWKKGxUOyC/ufsmo5mqy6tcR5E82yRqdUff1mvnVLrgR0QE202nG5JWIcG/E50wQIQ3gl1ObBmbK3NWF8fDOJdYSY++XY/ZgX7yzb7IjoAC5YB6pJ9YAKEq313gN5fytNZeUxhaDzzcC7mJ4ALuJE5RFvmvhlMpf5eRwki162b/R6xh0Krgsur2kTyoQuQYG9NcTzkO/fNat4gMf5C0N/ftqNOES0nOBgGdBkUWOfJXp6nXVLydLBM1gLVbbgLY4ESj/Ya/dxxXmRaqVJsV0jbC6bDaMPlVvrzCaKE+CHDGD/8QlVzH3WDfpu1xmg9VAEbv/A/9Tncxgdq0PPDA== Received: from DM5PR19CA0021.namprd19.prod.outlook.com (2603:10b6:3:151::31) by BN8PR12MB2883.namprd12.prod.outlook.com (2603:10b6:408:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 1 Jun 2022 03:44:28 +0000 Received: from DM6NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:3:151:cafe::3c) by DM5PR19CA0021.outlook.office365.com (2603:10b6:3:151::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13 via Frontend Transport; Wed, 1 Jun 2022 03:44:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT036.mail.protection.outlook.com (10.13.172.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:27 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:27 +0000 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.22; Tue, 31 May 2022 20:44:23 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 0/7] ethdev: separate metering and marking from policing Date: Wed, 1 Jun 2022 06:44:01 +0300 Message-ID: <20220601034408.2579943-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220522105102.1692526-1-akozyrev@nvidia.com> References: <20220522105102.1692526-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-Office365-Filtering-Correlation-Id: 9f080413-2420-443b-da02-08da4381076f X-MS-TrafficTypeDiagnostic: BN8PR12MB2883:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MP20VzKPnv6BzXsVPpNJ+SZAsO9vwtrlSG+oiWtZgcjksYNQU4AR3i1e+rNOmmhUaGp/aMpiPU0htOjre15ZnKWL0XMSWpxwh65mUPs2BmRhl/LwWRhWgcxrb/RoX9bCH4dN2KTtGJoGXlNsRmutfP0dwD8CxRO5HTwiQsi3MP7cHqioLHdSmPzIaQGK49Hra3B70exNNdswdo3pXKmo9Vvpc5t+UfKCCoSxx/mbbWMXcZPAE37SDH4QzRZfpdbepOMVX3kM7389FBiowAHiZc1SgNAZOP522fakXdWq2kgT3UMB5rqVa2GuEgvfibarodCHQ8ArTBYynQ8l2btlgbyKddrOQ0QcS4fx2K6oceHkzwKh+CgbMR+YQCUa1Sghh+vjnasi5XbuRGRGYS19pQZ6pDMlpLmiAgVTe0mLwNmkUlwVXmb4LiQGivfa9Ut7dWJUtak+tRXGAoWOZVQK+p2eqrlYco4TzioOwhVHEjKn56Fe2o76kjBt7gUMNHT2UNeb2i0I+SkoBbU5DS9Ukcm50wqESBGKmTRRxluK8b5rlX+G62ntg+c5enFC4c7Ex4CnZO5/ZD0T1ufAzByor/k6FhdmvfJf8Dv+hLaBP6J/qkzB+INkrQFYkyBAPVpVrj/Bd9X7D9xjOUHnoBWRty7KXl+S1r2LbyQvZ+27pc4SHNmnFnuCThQYnktz9yGpHyZTlwXIo+l+5tvrWukiwGRhFV+QxeldFN/Sm6jck3bxn8JK+Bmn5dSkrF8CPcW5aIvRaipd893iAavLZ61o0Dm/BnQ+KGtOcPzlSaLN7H4= X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(70586007)(54906003)(36756003)(7416002)(86362001)(70206006)(316002)(1076003)(8936002)(4326008)(8676002)(40460700003)(336012)(186003)(426003)(5660300002)(6916009)(16526019)(2616005)(81166007)(83380400001)(508600001)(36860700001)(2906002)(356005)(26005)(47076005)(82310400005)(966005)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:27.9865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f080413-2420-443b-da02-08da4381076f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB2883 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 Extend Metering and Marking support in the Flow API: 1. Add METER_COLOR item to match Color Marker set by a Meter. 2. Add the ability to set Color Marker via modify_field Flow API. 3. Add Meter API to get profile/policy objects. 4. Add METER_MARK action to perform Meter color metering and marking. Provide greater flexibility in how Metering can be used. RFC: https://patchwork.dpdk.org/project/dpdk/cover/20220502200439.4100965-1-akozyrev@nvidia.com/ Traditional Meter Usage: profile_id = rte_mtr_meter_profile_add(RFC_params); policy_id = rte_mtr_meter_policy_add(actions[RED/YELLOW/GREEN]); meter_id = rte_mtr_create(profile_id, policy_id); rte_flow_create(pattern=5-tuple,actions=METER(meter_id)); The METER action effectively translates to the following: 1. Metering a packet stream. 2. Marking packets with an appropriate color. 3. Jump to a policy group. 4. Match on a color. 5. Execute assigned policy actions for the color. New Meter Usage Model: profile_id = rte_mtr_meter_profile_add(RFC_params); *profile_obj_ptr = rte_mtr_meter_profile_get(profile_id); rte_flow_create(pattern=5-tuple, actions=METER(profile_obj_ptr),JUMP); rte_flow_create(pattern=COLOR, actions=...); The METER_MARK action effectively translates to the following: 1. Metering a packet stream. 2. Marking packets with an appropriate color. A user is able to match the color later with the COLOR item. In order to do this we add the JUMP action after the METER action. 3. Jump to a policy group. 4. Match on a color. 5. Execute actions for the color. Here we decoupled the meter profile usage from the meter policy usage for greater flexibility and got rid of any locks related to meter_id lookup. Another example of the meter creation to mimic the old model entirely: profile_id = rte_mtr_meter_profile_add(RFC_params); *profile_obj_ptr = rte_mtr_meter_profile_get(profile_id); policy_id = rte_mtr_meter_policy_add(actions[RED/YELLOW/GREEN]); *policy_obj_ptr = rte_mtr_meter_policy_get(policy_id); rte_flow_create(pattern=5-tuple, actions=METER(profile_obj_ptr, policy_obj_ptr)); In this case, we define the policy actions right away. The main advantage is not having to lookup for profile_id/policy_id. To free the meter obects we need to do the following: rte_flow_destroy(flow_handle); rte_mtr_meter_policy_delete(policy_id); rte_mtr_meter_profile_delete(profile_id);. profile_obj_ptr and policy_obj_ptr are no longer valid after that. The meter profile configuration cannot be updated dynamically with the current set of patches, but can be supported later on. Now you have to destroy flows and profiles and recreate them. But rte_mtr_meter_profile_update()/rte_mtr_meter_policy_update() can have the corresponding siblings without mtr_id parameters. In this case, we can update the config and all the flows using them. The meter sharing is done via the indirect action Flow API: profile_id = rte_mtr_meter_profile_add(RFC_params); *profile_obj_ptr = rte_mtr_meter_prof8ile_get(profile_id); handle = rte_flow_action_handle_create(action=METER(profile_obj_ptr, NULL)); flow1 = rte_flow_create(pattern=5-tuple-1, actions=INDIRECT(handle)); flow2 = rte_flow_create(pattern=5-tuple-2, actions=INDIRECT(handle)); Once we are done with the flow rules we can free everything. rte_flow_destroy(flow1); rte_flow_destroy(flow2); rte_flow_action_handle_destroy(handle); rte_mtr_meter_profile_delete(profile_id); Signed-off-by: Alexander Kozyrev Alexander Kozyrev (7): ethdev: add meter color flow matching item ethdev: allow meter color marker modification ethdev: get meter profile/policy objects ethdev: add meter color mark flow action app/testpmd: add meter color flow matching item app/testpmd: allow meter color marker modification app/testpmd: add meter color mark flow action app/test-pmd/cmdline_flow.c | 213 +++++++++++++++++- app/test-pmd/config.c | 26 +++ app/test-pmd/testpmd.h | 4 + doc/guides/prog_guide/rte_flow.rst | 32 +++ .../traffic_metering_and_policing.rst | 7 + doc/guides/rel_notes/release_22_07.rst | 7 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 + lib/ethdev/rte_flow.c | 2 + lib/ethdev/rte_flow.h | 60 +++++ lib/ethdev/rte_mtr.c | 41 ++++ lib/ethdev/rte_mtr.h | 40 ++++ lib/ethdev/rte_mtr_driver.h | 19 ++ lib/ethdev/version.map | 2 + 13 files changed, 461 insertions(+), 1 deletion(-)