From patchwork Wed Oct 6 04:48:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 100558 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 5BC15A0C45; Wed, 6 Oct 2021 06:49:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2285C4139D; Wed, 6 Oct 2021 06:49:02 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060.outbound.protection.outlook.com [40.107.243.60]) by mails.dpdk.org (Postfix) with ESMTP id D479B40685 for ; Wed, 6 Oct 2021 06:48:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8hxukZgW4qm55lZIEeJyLKKus3pf1hc2bin4DgWmJV/fHky7yfG6wTLCOnygsPLUyz90kFjkNfvg+NEv48OXKbFqTSZrHrnWXcHTZ7RU/B1LFmKnYwAMvshpHKHZg+3kP37gbI9tVcwUKzqn+rX8GIY0pHR8cgGnB2mlkmZYhvicRZPSlkLQEPoxqIAD20tBc81CiHavx9Fw0/t8071p4C0P2o2dx7fipH9CeWQLgrJjNDDbwAF2hMbhPY2RqrP0nCQ0rcxzYsi3u5x0Ohq4+/Z3MaZYVW/PlvYoSnWUYF8/A/TuAchqMDtL47jcfLdeu5HUVk/KTkTA7/u24l5sA== 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=5Az1N2gc0xWqGWEPuTVTlMmoRnBS+/A8FKZgHJHDlTM=; b=FdaKEXgB0i5aKcuUp2SHVuB81Vv1v5HTwbJmrVi4TdxD0pNi087gE5nfYIPxdPofY3qXLRhCpodbj8Hwyo5cKO8cfFdgyQPDa0OOcsc9DfClqwUJWIwzN5j9KOT1TxauPDkJoGpB2NA5JAKjGX3WN4mE1vph/61mJxxA0WWTgR85W22MgBZM+AVFSvkmh9Tgms7O4TcoUYlaRY7MZKFzmTmAH65Npp88tTpKGSXpxX+9xg02Yu5nNUwq+8Em2JT8bB3eXmcmzQ0xcTb+rnPZH/oONu3CTJlmTg/uZiWYkqZl5ABgsfBDk4O8gLJoKQg7wD2Z/02Zpdp1MXISkvkKWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=5Az1N2gc0xWqGWEPuTVTlMmoRnBS+/A8FKZgHJHDlTM=; b=NiQzCmoMBUasJrIQ0UrEDe2E/SNlPPro00cvQeatHrt2LPE10kq62VP+JjosIg2+pr9omlvsluC7uFmfL1vvyoZ2TXjjMmcmQJiM/4/YQCq0GNbd+GZDLra2ipyq85yigZD/o/WXBbpuKpEngKYquqpUwNDLtGXEyQB0cdjvFPl/WWTbV5hmdVSPq+8tcMQoVb9Z6URRefT0rgsrgr7CjqNWjBRwkaYVQLGYu0hyIUotTWSjbO1FWvQl+u+HtCYMHBSIihpfjMWutP0scoPyJdhUFO8uw92ZSd9TjDtARWmuM0ZaZlbygNVqTJzOpJmLlVZrF0tvSIMT1pcV/pT/IQ== Received: from BN6PR2001CA0006.namprd20.prod.outlook.com (2603:10b6:404:b4::16) by MN2PR12MB3822.namprd12.prod.outlook.com (2603:10b6:208:166::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Wed, 6 Oct 2021 04:48:54 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::d1) by BN6PR2001CA0006.outlook.office365.com (2603:10b6:404:b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 04:48:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 04:48:54 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 6 Oct 2021 04:48:51 +0000 From: Alexander Kozyrev To: CC: , , , , , , , , Date: Wed, 6 Oct 2021 07:48:32 +0300 Message-ID: <20211006044835.3936226-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad376343-2dbd-4c6c-f4db-08d988849986 X-MS-TrafficTypeDiagnostic: MN2PR12MB3822: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qAhLAwUKsvMGRRjvMxk7qhZsbYFVrOXPdfVjA6AAoov5OSBZ/2nNDPz1wWMkGoFTNLSiQp0s8xwAbtbRHHsHIGPGeyLsFXUJYi28c0IWewB6M85ERXfmhifS/vF2rRwYotkqP/Q/f5EpJUp00PQSRnK7Fg/RTS/3KKny2t+V0Z8eyLmSDr5jV59uOhCTlIdESuA4ZMGCfJ7YQKmpV03nZxxEBCpom12QoKjlG8GtxQ4phTapR6IT5xKGEOc4pJPbskDVlhVrVz1YV27ONf+mIUiTTRMpIfuCHABmft+ghTf+51MeUH7qOJvxb22KtHw6L2ZWVZQKcJxjp7YnZNL8tR+a3qVfSaa50iZPni3jficxmep23foMlS/EJnwPLOVpsJZShevIMrKYfwc/MlC0k94uY6Dc6Hl0fxcD8j7p9YxHsCDz/Ne3JvTEueh7sbi4tlgrbLo2JEM3Wgzi5xF9RXrBbRNmek02zjy/mlEUrIZcmaSO0L/8Tuvi3IgpRNE7K4U/XYPVtzc8RVSZfncpMsMi5NO/adQI4P/LW7oboruadsTawBW3PmsJoiojIGIJMmqMNkurfIfh5SNtWhhUj8eeGMnwXbY4nDoJle0D4daAXBXBG6b8u1cGRp3B/aczaFB0Cmjjg51lA9n8xdjRykMEOnAiOrMriMxt6BWU46fBCBO36WMj1yWNAzoBTuYXxHTdwqWONOc/lYVqgXIm7g== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(2906002)(6666004)(508600001)(55016002)(47076005)(336012)(1076003)(82310400003)(7696005)(86362001)(426003)(4326008)(26005)(16526019)(2616005)(186003)(8936002)(316002)(54906003)(6286002)(5660300002)(356005)(8676002)(70206006)(83380400001)(7636003)(70586007)(36860700001)(36756003)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 04:48:54.0785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad376343-2dbd-4c6c-f4db-08d988849986 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3822 Subject: [dpdk-dev] [RFC 0/3] ethdev: datapath-focused flow rules management 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 Sender: "dev" The current flow rules insertion mechanism assumes applications manage flow rules lifecycle in the control path. The flow rules creation/destruction is performed synchronously and under a lock. But for applications doing this job as part of the datapath, any blocking operations are not desirable as they cause delay in the packet processing. These patches optimize a datapath-focused flow rules management approach based on four main concepts: 1. Pre-configuration hints. In order to reduce the overhead of the flow rules management, the application may provide some hints at the initialization phase about flow rules characteristics to be used. The configuration funtion pre-allocates all the needed resources inside a PMD/HW beforehand and these resources are used at a later stage without costly allocations. 2. Flow grouping using templates. Unlike current stage where each flow rule is treated as independent entity, new approach can leverage application knowledge about common patterns in most of flows. Similar flows are grouped toghether using templates to enable better resource management inside the PMD/HW. 3. Queue-based flow management. Flow rules creation/destruction is done by using lockless flow queues. The application configures number of queues during the initialization stage. Then create/destroy operations are enqueued without any lock. 4. Asynchronous operations. There is a way to spare the datapath from waiting for the flow rule creation/destruction. Adopting an asynchronous queue-based approach, the packet processing can continue with handling next packets while inserting/deleting a flow rule inside the hardware. The application is expected to poll for results later to see if the flow rule is successfully inserted/deleted or not. Example on how to use this approach. Init stage consists from the resources preallocation, item and action templates definition and corresponding tables create. All these steps should be done before a device is started: rte_eth_dev_configure(); rte_flow_configure(port_id, number_of_flow_queues, max_num_of_counters); rte_flow_item_template_create(port_id, items("eth/ipv4/udp")); rte_flow_action_template_create(port_id, actions("counter/set_tp_src")); rte_flow_table_create(port_id, item_template, action_template); rte_eth_dev_start(); The packet processing can start once all the resources are preallocated. Flow rules creation/destruction jobs are enqueued as a part of the packet handling logic. These jobs are then flushed to the PMD/HW and their status is beign rquested via the dequeue API as a method to ensure flow rules are successfully created/destroyed. rte_eth_rx_burst(); for (every received packet in the burts) { if (flow rule needs to be created) { rte_flow_q_flow_create(port_id, flow_queue_id, table_id, item_template_id, items("eth/ipv4 is 1.1.1.1/udp"), action_template_id, actions("counter/set_tp_src is 5555")); } else {flow rule needs tp be destroyed) { rte_flow_q_flow_destroy(port_id, flow_queue_id, flow_rule_id); } rte_flow_q_flush(port_id, flow_queue_id); rte_flow_q_dequeue(port_id, flow_queue_id, &result); } Signed-off-by: Alexander Kozyrev Suggested-by: Ori Kam Alexander Kozyrev (3): ethdev: introduce flow pre-configuration hints ethdev: add flow item/action templates ethdev: add async queue-based flow rules operations lib/ethdev/rte_flow.h | 626 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 626 insertions(+)