From patchwork Wed Sep 21 02:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116507 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 9016EA034C; Wed, 21 Sep 2022 04:12:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2620740E0F; Wed, 21 Sep 2022 04:12:19 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by mails.dpdk.org (Postfix) with ESMTP id 11A5F40697 for ; Wed, 21 Sep 2022 04:12:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GAgBWzu8GS3E7p/lGg8J3VSIoAduB4B+G/7VJMtNDJ9SImYeUdxoF5LbRNZ2fz9Y9ag7kvlOJZWcs4d4zuj4XX66fZOhkWw63+zdSDGfdpY6GsIe0dwqAbhIGah6ssfwQHwaNAJ0MBes83MBP4RSbZpIZNyN3z8qqrKLJ+nSx98MZJN+xfsGiSrNkUcjahbhEwF8WNjVI1WuNq5BIi0Uey4rBFHZnURsHAUqymycdL7LFA7p+tCA6HdX2ML3tFV6g8ojPb+HVpvy2z+oIH5uSE3gTsVCLagZyGKF8Om7HfhGhWfMqcyzAbisEVnzJeQeVrABxf+0CTnpGSKyIJhk2Q== 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=fjBshymfPY0UAIbsnVmgs73Fcb2pMKn8oxSo4rXKQR4=; b=djs4vYAyornYDwAjaVuHPOKYvcxAyvvqQ3Ug2zOIfq+Xn9Ug0TIEJniW3OMmVrAIcIeXxoYj14CDsUBDNfzOki0bewcaqwN7t2x2QGJSgP1i4sAPbbVODMXnBCQZ64AAEkSXMfIUbHjrkBXYkFF7pZCyNRRyW25cjMHmKrASrSDy0nS0FszFdKlRDMSzttlqOv4cY7658Mvh9YZBFV9fEVmWtvqSRMqiMvq6vsG7Yr59GDI3QpUtep2ajW1K/JDB7Hy9lx4AsprIpiBuLsxR3sXZ0pzv5B/9o69QlKw21LjH88kIylHRLUmf105fr34rCGDsXEaALff1dnlmF2QqIA== 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=fjBshymfPY0UAIbsnVmgs73Fcb2pMKn8oxSo4rXKQR4=; b=kwUwBEungXAV9O19hoN59ddAo5U4Y7PB1pKaFrgL06Un3BTPkREX1U+xfY3urr70Tor8b4ZSCkIZN6UIrLQOs03FjUcd/O3OXrpDAlJw0EWRvH5OeFhwaw/R9pqj9/7SP16MX2HDZxyf50PFzq2bMrrD0Aypzq6BjUyynHvIyxsq/CLh8Q02EYn7iTzdrXfR/UBnPW3HV/v8vVtT5dadb5DT+2wXY/GGmaXJ2ugh4fhvRFd9axtpKMH91fVJnBO2S1jqEYwJke2i34PzvIMz4dVWMK4KdM+8b6lcuHeMMJ86UJDX9iva468U4t57F6Pf7v1hB2/S+vIn0cdJpCFKcw== Received: from BN9PR03CA0647.namprd03.prod.outlook.com (2603:10b6:408:13b::22) by MN2PR12MB4304.namprd12.prod.outlook.com (2603:10b6:208:1d0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.15; Wed, 21 Sep 2022 02:12:16 +0000 Received: from BN8NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::81) by BN9PR03CA0647.outlook.office365.com (2603:10b6:408:13b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Wed, 21 Sep 2022 02:12:16 +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 BN8NAM11FT088.mail.protection.outlook.com (10.13.177.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Wed, 21 Sep 2022 02:12:15 +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; Tue, 20 Sep 2022 19:12:02 -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; Tue, 20 Sep 2022 19:11:59 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v4 0/7] ethdev: separate metering and marking from policing Date: Wed, 21 Sep 2022 05:11:26 +0300 Message-ID: <20220921021133.2982954-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220601034408.2579943-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: BN8NAM11FT088:EE_|MN2PR12MB4304:EE_ X-MS-Office365-Filtering-Correlation-Id: ff3baf04-b0df-4461-bf12-08da9b76b440 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: sPk/JyDfvlp2ca3ejh7KEnVe4Qqd7rlwYRLycjRoUmn3oXWukZ53gQWQRJWPI4YRzBtyKHH6l1EMZixwwap0qCizEfhDbRNP24DlVf5qybX50WBPXB4uPaEgBFGczfxZ75aHbnjm0lq/gctk6QWWGQrqBUCGvGvc1gmK6wHCzdnwMa0n9VKJokoHC563n2htzmixPTLVZ546+6FZ4QTTVygeb9Tlp9h0l8dQBKvjMfct4rb7ZpAtFo8LUebGjcK5GJ2DpnT89Q+qMy8J4kXCOwmXtiJVobE1zbhuOJX8tAK0Q1ZLXdgep978pM/AhiG4oHWcLFUumCuwJWNUF5R6jqWnKsexWB9TAHpD0ZCZ0gS4dfL1oZ7WGqJLNQdYJDYD4iEaoxe01+cQonkubAkGH1AfhbDJUWetB2ngbv0nJxfILj7RHlpTptcBrBum5yFV145MeGvVAnD1sQ7gKWL+6ba2mUHUv/63rUupoJY4hr/eFuIFeQOVTiplvji0gzGWPfUwLUjiDOfQwscUdajr1rnMJ9OVnoioBQE27rXI9yG355/zeZT1ryv42K11y+paT/o4JoD9X7mERNi6uo+xOvNjiZtGkZiMuh7FoCw2an9dWtJHMEBjt2OgoZbUjUUgorweVj79UtzxRlEi80yQYvZfJxFDa7I78Qmf8QjsDSdMU8OSCmyOItAdBf7+8NFWtCmYfZBQseAEAA4evJf35mYf1V2vEANQ4fLASUI49co6l4Bu02cdh0pnl6SRNoHtbdHdYrdStR7RGGNIJBMHqrlAh3AvQBFK1t6Ne6TslSnbDsD/Iy0OF/lWsys6hFE7JTske7T+qJGFtAVjFTaMYN/vuiRgUrjSyQ5E7K3KhBY= 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)(396003)(39860400002)(136003)(346002)(376002)(451199015)(40470700004)(36840700001)(46966006)(316002)(41300700001)(86362001)(8676002)(6666004)(8936002)(356005)(82310400005)(7636003)(26005)(4326008)(478600001)(36756003)(70206006)(70586007)(54906003)(6916009)(966005)(1076003)(186003)(2616005)(2906002)(47076005)(426003)(16526019)(83380400001)(40480700001)(336012)(7416002)(5660300002)(82740400003)(40460700003)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2022 02:12:15.6903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff3baf04-b0df-4461-bf12-08da9b76b440 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: BN8NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4304 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/test-pmd: add meter color flow matching item app/test-pmd: allow meter color marker modification app/testpmd: add meter color mark flow action app/test-pmd/cmdline_flow.c | 212 +++++++++++++++++- 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_11.rst | 6 + 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 | 4 + 13 files changed, 461 insertions(+), 1 deletion(-)