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 9F244A0C4E; Tue, 2 Nov 2021 14:54:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FAE841158; Tue, 2 Nov 2021 14:54:37 +0100 (CET) Received: from AZHDRRW-EX02.NVIDIA.COM (azhdrrw-ex02.nvidia.com [20.64.145.131]) by mails.dpdk.org (Postfix) with ESMTP id 61F444114A for ; Tue, 2 Nov 2021 14:54:34 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by mxs.oss.nvidia.com (10.13.234.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Tue, 2 Nov 2021 06:54:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YikUlUsFVUDsYt5LEBj5CsA+W3jhI4Wz+32ItFcrzil40p/bwjm13v4Q9eNFCZV2/TnQNREy6F6mCAAEn9jrilR8VAr1E7a/WeMpn3jZjHS8BLOFcA+ZgWnOEInRVt/fu1XcFqFphtuaKYZGJVGjfqPQcwf4LC10i6YNhRisfwrrf/lZIivvu7mIMRkJKUXdPDXCTPLTy+d38ehmSXDmv3kmNDKUr2ks9Kz2/kPHod3T+P46T5V++WwspxPVKmm0BR6+osZ72ufldVcC9RWBi8aFwNeV64me3I2lMSu6v6Rvx4GjtDR79QLbsHyeAfU2Sekje+2Um3QPhLl07xBWSw== 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=/P/kTHM58kQdpjo2ltSVSSQzdhYRBK0c4x5KMXvqVU0=; b=RI/eaiKz2R5Wmp5f1QbJ+Dk3pRqPSMaWC34xog0RytBeZ5Qc6c/mwS/bIcIu7DBBpRm/ZZEvAfar8l4Ewmu0TzjVCuOyCmSiWWgz8w/4tp0RDYPenGa437OukpYI6zfdoTT4Kny3LSfgv4TGKup7Ec1wwyfGx1lTTRW7nxozLS/XUvLwG3ZvgrEIamyxzgEDihZ1w+83bIsbEzzGsWjoaVuGTJRpxLoR5gTaeu560LDyjUGoq/0Xi1etB0imCr6ivupMWv9ZRnXyZl20sja8OYxS48OyMMNQE0Wo3SsX03TKaleCvhDgOR4ZXEN7gYYeZELrnLiMvtMatrJKOLrfeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=/P/kTHM58kQdpjo2ltSVSSQzdhYRBK0c4x5KMXvqVU0=; b=DRidDAoeiEWWbJRzlLXE9prvNhEvOxy3VayIg7rqTqw7Ezr9u7IeG53DTZhbbyI5gJd3LOkn4IQfhuBHsPCC9BKMTDjHeSf5sw1d0y/56/XPEyP+5Azhm78DzauhmqDpPTtMbHXafUVDfef71kHRNTUpDceDRAOkaBL234nb5FxOj2w3zSag1zs7tfRQo3FI6FLonsgEM0z6dB3Ee4D4c/fXgboMywQi5aaNhumYiTR/FAb/N+Z0J9781kygi72oe7RLdSFCiJ7SDNGt9r2g55bmJDYX/mAgeqS8wDkbrpT+SY7TSLtZbj/DFKMgnps8w50RD10/4Cp75MffUYiLHA== Received: from MWHPR17CA0088.namprd17.prod.outlook.com (2603:10b6:300:c2::26) by DM6PR12MB2779.namprd12.prod.outlook.com (2603:10b6:5:4f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.18; Tue, 2 Nov 2021 13:54:32 +0000 Received: from CO1NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:300:c2:cafe::5e) by MWHPR17CA0088.outlook.office365.com (2603:10b6:300:c2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 2 Nov 2021 13:54:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 CO1NAM11FT031.mail.protection.outlook.com (10.13.174.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4649.14 via Frontend Transport; Tue, 2 Nov 2021 13:54:31 +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; Tue, 2 Nov 2021 13:54:29 +0000 From: Dmitry Kozlyuk To: CC: Ori Kam , Andrew Rybchenko , Thomas Monjalon , Ferruh Yigit Date: Tue, 2 Nov 2021 15:54:10 +0200 Message-ID: <20211102135415.944050-2-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102135415.944050-1-dkozlyuk@nvidia.com> References: <20211021063503.3632732-1-dkozlyuk@nvidia.com> <20211102135415.944050-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 235c2a55-9c33-4e52-cc87-08d99e084bc1 X-MS-TrafficTypeDiagnostic: DM6PR12MB2779: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: 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: 5Mi9igMwnZnUPHgEsu3Rr/jWrVbk4deIDX1WGlN87r/bmFJIA7p/VTHlt4etWY9zXmJDDCtDRerSBZrednEz2yHb5uDVngdSRXFEKvzK++wgUesS+am4p3BlaPYoUYi8HhjYq+vkfzOVXcZNk9iiV5KVRgo8Bwa21BL2SHfYm1ZoPdD4vlrBPlLVGP2VTe/Lrp5N11WzEAKE5DuXwKTNJSAz40ekkSceyuxQpP7Er1LSLhKpakemFrzfxl5FQgfKGabNFwS1SNhBQiWyUHQjUYM3xeG9hY3SzrxGOcjBP5hFNDNeMUeHKJ07VYmCvHT8nU/ZhhV57ylxxlBZIuC9rYhjGA6JqBzYLd5nchiWgLhA+c3QgGQJMy4tTs/hnE/RrSRFPu6l8hIAWq1KnMdHTphAUfXxaoLHimzQlaqiwRc2LlBJBh2Un0yDXo0V+XROXhBzIgGsAiMyCKs/7IYhN6dmIV3zRI7oP4YJx96pqGVL5hs+/RP2Ydw4TwUfTxQ8SBCjbxMZPnmbYSzC4XR5w9YQzsC0oqqEut8q120xey7AWmMAjgRFou1JdX00e5r219g0w03jWnrzYrE9rvBiSuPkLHKIzzpBJa3jTZ/9vtfHXYT7zXydmzKMV0bdBagRKTkf0+5Kb27UyYysQ1iixhMZvLTKiRgXobft8NLS/QHY0CImvaPrJv9NYuwVoGMmpHp7dzCe+BnvioOkSJyw6Q== 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)(55016002)(356005)(5660300002)(36860700001)(83380400001)(2906002)(2616005)(82310400003)(8676002)(86362001)(336012)(6286002)(107886003)(47076005)(70206006)(426003)(26005)(7696005)(4326008)(70586007)(8936002)(316002)(6666004)(36906005)(1076003)(54906003)(16526019)(186003)(36756003)(7636003)(6916009)(508600001); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2021 13:54:31.6395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 235c2a55-9c33-4e52-cc87-08d99e084bc1 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: CO1NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2779 Subject: [dpdk-dev] [PATCH v5 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 Acked-by: Ori Kam Acked-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 36 ++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 7 ++++++ lib/ethdev/rte_flow.h | 1 + 3 files changed, 44 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 2d2d87f1db..e01a079230 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -87,6 +87,42 @@ 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. +.. warning:: + + The following description of rule persistence is an experimental behavior + that may change without a prior notice. + +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 24f30b4b28..a18e6ab887 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(). * @@ -1691,6 +1696,8 @@ struct rte_eth_conf { * mbuf->port field. */ #define RTE_ETH_DEV_CAPA_RXQ_SHARE RTE_BIT64(2) +/** Device supports keeping flow rules across restart. */ +#define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP RTE_BIT64(3) /**@}*/ /* diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 85ab29b320..ebcd3a3c8e 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3748,6 +3748,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