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 70C7AA0C4B; Thu, 21 Oct 2021 08:35:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CF3141194; Thu, 21 Oct 2021 08:35:41 +0200 (CEST) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id B82454119F for ; Thu, 21 Oct 2021 08:35:37 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.176) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Wed, 20 Oct 2021 23:35:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kqkr7AFcmK6HgRYey2J0WcBSedj2tL1fz7sq+NHV+W/KLgmWU8faJr9970DGYfGy2Y1ErDFR/Z6Yhklmgs7cm3NIQZAvhSVRT7W1kKUXOqTq0FkfR5jX5zMcJtCR4N4Hrk8peee6sjYA9vdl6v88m4g0uahDGz8AgoX+d7vmYNIFyA6qZZcehwpjFH4h+nOdPcgxNmhvFVQLXkLM3WjK5toJt78aFWYtHgeqcmwLUWOJPe3d0O6ufaokxsdptWv/FbLf1WKCxjeDAbSUW5/NZg9XqSO/i6KXiyd9oZsjQzo9qUB6o6gwNs7j7A/Q/kufkJ8rMDxSExpQ21dfTa6P7A== 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=oQPOTOr7llLhM2rv+oaMKHXOBy9Goxao4BNntA9UYtc=; b=jbZQTq5vJYUxiZTc1ghFob3ybiEzdoJrsYm8UUtu0VDVaJB04WBN7uZB2SbwWi6YECzGsVIf71fG1uSrxSnoLW/O4Tju5NOyjWS6CpqAv/T+VEPkd5OOwkeXBF/e59UpeFqYkurzvIsTOx8KK9sjZWSUWpaAxR41vEyDDzeK3R8nQvp4/ugOlj++bVQpIaVCX5NCju/kIo5X43IwK2yL37mGmFYP3HZ+980hLBf3o5qXt6TtUkyQoyPuNWDiigDbM1d8KUWhwChm96XnFxkHcZpfqR/VVVA2kMq0TLWxYkqtPKAFgc0p92QxbjFr4YosqrSmPB/8zK6UtFZREMjd6Q== 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=quarantine 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=oQPOTOr7llLhM2rv+oaMKHXOBy9Goxao4BNntA9UYtc=; b=qvDy4Z4fvF73MXQlvvmtCeqQDYnNz/mBGIEPUd/4cXTqxJb24WyAYdDmRFSXyM1vRP9UPWO7CywWL8+JyddbzFUBveFLLGYViazkaLN0Kub5wyOGAc2ohdUZzL8mBuIa/wjIVrRTw9i24F2jlYht6p+A48VTK0q2y15FgGvVfEdx6E14bEZa6H6OBsBS+vWv2JlEI8kvkSIkPWir9y+Ep9uz6VLbwII3AV8dHjTmj3X3CTJlN6VWNKaNUlPEJbgzniQaaIsHOHKpsjKTzPRLcI7YC2SAWBhwVQHndjEJ1iBs5s9dxK2FHqT6srGopNT5R9Rd6lJdjd4KEUXtUaJvqQ== Received: from BN9PR03CA0298.namprd03.prod.outlook.com (2603:10b6:408:f5::33) by BYAPR12MB3381.namprd12.prod.outlook.com (2603:10b6:a03:df::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Thu, 21 Oct 2021 06:35:34 +0000 Received: from BN8NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::b4) by BN9PR03CA0298.outlook.office365.com (2603:10b6:408:f5::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Thu, 21 Oct 2021 06:35:34 +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 BN8NAM11FT048.mail.protection.outlook.com (10.13.177.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 06:35:33 +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; Thu, 21 Oct 2021 06:35:22 +0000 From: Dmitry Kozlyuk To: CC: Ori Kam , Thomas Monjalon , "Ferruh Yigit" , Andrew Rybchenko Date: Thu, 21 Oct 2021 09:34:58 +0300 Message-ID: <20211021063503.3632732-2-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021063503.3632732-1-dkozlyuk@nvidia.com> References: <20211019123722.3414694-1-dkozlyuk@nvidia.com> <20211021063503.3632732-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cf0cdd2-5690-4158-cf9c-08d9945cfc07 X-MS-TrafficTypeDiagnostic: BYAPR12MB3381: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 41przWB7vgTirpPrtf9hxQMFpbkN/NR9lNKZQgrX5nvSWehT0aaKEKANcH6CTUxbIk3bs2ZUKvT78/1ONr554Qy9j0ykXZSUCzeGEGUjlR7a2afsspy9YjrQ9QI8AitNd5UByOxv3nNq5vKw+1NXs6oFCAWkZYrrOdOKQo5NYkl83amCwFDWM49jGKJGcm0RhXvqf2V2qvQYVQq1FvF8Nxphb26JVTym+5TpCEiZ3wQ9WlIe8bWZQoUut/OGUE4fqDBfV8ZT8QVoZyt+xbDaiOXpBtKnrZnVFqWCxl8WrgYxUvDV6VEDxd2gQbfbjalSVP7uomqWf2OIbV3PorpmBVC40sH6vIxWDUPQq+gPnqKeDNyiPVKgs3QmIVRLI9hV1+EbenalVs/sJJLi6jJbwJN+wKW2QHNTgFw4tb41DnPO5eRYTNyxG5qGHRzJG5ebi4g4WYEj+kA3e7JehW/4gvEPxefnJhylpFlMJgqlNO1mm+9c6YPSZRwr5W2h6fyehSRN8MM86ysotWLZL0CKsXzvPrgi3TFHV4PpRhS/JbAtMPdMLHTDbe7Rho/2XfY683E2TlbKRyT+8JyipRevvJDyWa3PnahRLMcpVT40AF067NxE0Dt7sKEIDBvQQqnwHaJl+2WBUcWmf0EeAUrRM0DFhmQWUgHJkL8PBcgb/OdiEioZA3/Ul+Tx55//U7wI1gNEq9ITbZbuO1u/YFphEA== 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)(4326008)(107886003)(47076005)(6916009)(55016002)(7636003)(426003)(2906002)(508600001)(86362001)(36860700001)(8676002)(316002)(36756003)(7696005)(356005)(5660300002)(6286002)(26005)(2616005)(16526019)(8936002)(83380400001)(6666004)(82310400003)(36906005)(336012)(70206006)(1076003)(186003)(70586007)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 06:35:33.4249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cf0cdd2-5690-4158-cf9c-08d9945cfc07 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: BN8NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3381 Subject: [dpdk-dev] [PATCH v4 1/6] ethdev: add capability to keep flow rules on restart 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" Previously, it was not specified what happens to the flow rules when the device is stopped, possibly reconfigured, then started. If flow rules were kept, it could be convenient for application developers, because they wouldn't need to save and restore them. However, due to the number of flows and possible creation rate it is impractical to save all flow rules in DPDK layer. This means that flow rules persistence really depends on whether PMD and HW can implement it efficiently. It can also be limited by the rule item and action types, and its attributes transfer bit (a combination of an item/action type and a value of the transfer bit is called a ruel feature). Add a device capability bit for PMDs that can keep at least some of the flow rules across restart. Without this capability behavior is still unspecified and it is declared that the application must flush the rules before stopping the device. Allow the application to test for persistence of rules using a particular feature by attempting to create a flow rule using that feature when the device is stopped and checking for the specific error. This is logical because if the PMD can to create the flow rule when the device is not started and use it after the start happens, it is natural that it can move its internal flow rule object to the same state when the device is stopped and restore the state when the device is started. Rule persistence across a reconfigurations is not required, because tracking all the rules and configuration-dependent resources they use may be infeasible. In case a PMD cannot keep the rules across reconfiguration, it is allowed just to report an error. Application must then flush the rules before attempting it. Signed-off-by: Dmitry Kozlyuk --- doc/guides/prog_guide/rte_flow.rst | 31 ++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 7 +++++++ lib/ethdev/rte_flow.h | 1 + 3 files changed, 39 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index aeba374182..9beaae3df3 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -87,6 +87,37 @@ To avoid resource leaks on the PMD side, handles must be explicitly destroyed by the application before releasing associated resources such as queues and ports. +When the device is stopped, its rules do not process the traffic. +In particular, transfer rules created using some device +stop affecting the traffic even if they refer to different ports. + +If ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` is not advertised, +rules cannot be created until the device is started for the first time +and cannot be kept when the device is stopped. +However, PMD also does not flush them automatically on stop, +so the application must call ``rte_flow_flush()`` or ``rte_flow_destroy()`` +before stopping the device to ensure no rules remain. + +If ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` is advertised, this means +the PMD can keep at least some rules across the device stop and start. +However, ``rte_eth_dev_configure()`` may fail if any rules remain, +so the application must flush them before attempting a reconfiguration. +Keeping may be unsupported for some types of rule items and actions, +as well as depending on the value of flow attributes transfer bit. +A combination of a single an item or action type +and a value of the transfer bit is called a rule feature. +For example: a COUNT action with the transfer bit set. +To test if rules with a particular feature are kept, the application must try +to create a valid rule using this feature when the device is not started +(either before the first start or after a stop). +If it fails with an error of type ``RTE_FLOW_ERROR_TYPE_STATE``, +all rules using this feature must be flushed by the application +before stopping the device. +If it succeeds, such rules will be kept when the device is stopped, +provided they do not use other features that are not supported. +Rules that are created when the device is stopped, including the rules +created for the test, will be kept after the device is started. + The following sections cover: - **Attributes** (represented by ``struct rte_flow_attr``): properties of a diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 014270d316..9cf23fecce 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -90,6 +90,11 @@ * - flow director filtering mode (but not filtering rules) * - NIC queue statistics mappings * + * The following configuration may be retained or not + * depending on the device capabilities: + * + * - flow rules + * * Any other configuration will not be stored and will need to be re-entered * before a call to rte_eth_dev_start(). * @@ -1445,6 +1450,8 @@ struct rte_eth_conf { #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001 /** Device supports Tx queue setup after device started. */ #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002 +/** Device supports keeping flow rules across restart. */ +#define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP 0x00000004 /**@}*/ /* diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 2b6efeef8c..16ef33819b 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3676,6 +3676,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ + RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */ }; /** -- 2.25.1