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 4198E45BA0; Tue, 22 Oct 2024 14:07:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0EF540673; Tue, 22 Oct 2024 14:07:19 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) by mails.dpdk.org (Postfix) with ESMTP id D276940689 for ; Tue, 22 Oct 2024 14:07:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rIF/kkEu9/LtRf03efN+ELe0JDLrw4DLl+WiwDAMf5fTi1EERlde2cd07mkJIFWDLlE2iZT+HylMForQX1tgWEW3l1UJuruufEGob2wD0f0JQR3K7pQjV8k5JBorI0iCqJu2eCHZ0ruciSYLuXgbEFUV5PmEx9ehMEZ+Gc3a+3YjB7CngaqUQW/N+86h6+d5tQRooJcWAr3k6CxQ5SN++kR3VTyarj/c0QbIDsD4lkvvt5Tzilwh8lhu6qfC5jdSHcUKUUyNRY/ksHNaV8hWbN9dfKVJDW90nyWDWf2A9n4iD5AAdtxSEcdIvOx7veF3D0lP6ifW62QqGwE95Qeq3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kmxxZjmWFVELEKuwT679tFmhRZIVgvRs8mUfbdUH1G0=; b=O6Xj3O3q2YfNnVisyM0wA/uGN4VRTVvvjUHypq8ZRO1t0mlOhWasPv89NmDwLLoJozJFPSKQnZRC2XQGhJU7lTYoMWzcyrfN8b1J0Cl8rCUzabTJG0SoNKKJHnXFVB5tgnSyFzD1y8XlMJZScBC6QYIbThiK1GBRHtvck0xozh4fiyciyGxEalF4hVI96bgA7nl4Z9C39ivLUtZRtds/0wUn2QLnvmP3IL1db2ukkQgWrdtPe0WLSiHz154UyVl65P7b8k4bWSP+Gvfvmh4VmwUBNUR9U00R4w0p04re0AzJDcYyn+W1DhPUzwACKG/PgmzU1vv+4YzLAYxJ1wQ4pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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 (0) 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=kmxxZjmWFVELEKuwT679tFmhRZIVgvRs8mUfbdUH1G0=; b=LeHOBhXZsITIV5PJIjwTj2zxILNNuU7MG+E1S+RDp1vPbi9oqePSHBjsMW7Ur+5kK4QiMTOqJ/3YX0sQWVj8SwGDU758x/qJdwIzMr8KRdtkwMSk+F2yKpKSFVg6SwUVzzLMTMJ9UaEl42JrZOi0evLPq2Il3Pt5qD9gHlvSPUupSXZwpzMb1WkDh3TO9cqgDPwv9Dc6QqAJyy3UPpDFjYu7YZ+Fv/Pu7C1cyv66hZj6qpHkRBCIrGl4zDru/XpX1yUWkPZHtAbfcdBqH30O6cjVoBiDxvgOb43vAaYpNu2jJPXJyno0m/rQoj1dybrCwlRE55O9QEyocHiuClrbzw== Received: from BY5PR16CA0018.namprd16.prod.outlook.com (2603:10b6:a03:1a0::31) by LV3PR12MB9168.namprd12.prod.outlook.com (2603:10b6:408:19a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Tue, 22 Oct 2024 12:07:11 +0000 Received: from SJ1PEPF000023DA.namprd21.prod.outlook.com (2603:10b6:a03:1a0:cafe::cc) by BY5PR16CA0018.outlook.office365.com (2603:10b6:a03:1a0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26 via Frontend Transport; Tue, 22 Oct 2024 12:07:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023DA.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 12:07:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 05:06:59 -0700 Received: from nvidia.com (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.1544.4; Tue, 22 Oct 2024 05:06:58 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 04/10] net/mlx5: support destroying unicast flow rules Date: Tue, 22 Oct 2024 14:06:12 +0200 Message-ID: <20241022120618.512091-5-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022120618.512091-1-dsosnowski@nvidia.com> References: <20241017075738.190064-1-dsosnowski@nvidia.com> <20241022120618.512091-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: SJ1PEPF000023DA:EE_|LV3PR12MB9168:EE_ X-MS-Office365-Filtering-Correlation-Id: 286f5027-f2eb-42fd-dad3-08dcf2920f5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iGEQV06g5M/k/h3gqLDMpxle7nNlUYUp+7vI1W/pJr8k3jjmfHES4YYwuY+h?= =?us-ascii?Q?5+KU+yCACf/QQnFi6aQIlieADNtlSEofVM8+ziWUu17jpw3LfQEoRCNCBhCY?= =?us-ascii?Q?UowxIiV8TS9KxBd+2qI0ovL5pors/YbIJk74+8UNOFSFIklb1MBmr7e34V0q?= =?us-ascii?Q?luersyn27MJuEndT6YWbEHwj+FHdh+givZ+rKSSCasjYF+VDjc2UWe1fu5KS?= =?us-ascii?Q?8hm8nWPkv51nH7awu6NzgsFEVuxHM/Gqbp+lyqh8vGTKpWwvwCEceKmflqQL?= =?us-ascii?Q?qNq9RKwoz3cCnnOx1XN1/Tw6zLLQuXX/Ohgct7RiNSGshAkRZ8PA3LcRCj3V?= =?us-ascii?Q?NSCX37PzeV214X2q7PDwGuRgwtdPozYOUwLcgicyPSxOQ26urcqeGzQeb1LW?= =?us-ascii?Q?95Aqo5bDuQxxhvj16nwu8WpEY+NJSUyJNGPbeTrGuvyYCsvmurkE4ChC3Vsg?= =?us-ascii?Q?WwbQxfvifv583Q7796VGKZo/cL96xZbsv43Sag1YJT4TfnxE3m0CaRFSQhs/?= =?us-asc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0uc9SOaA=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 12:07:11.5317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 286f5027-f2eb-42fd-dad3-08dcf2920f5d 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023DA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9168 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 This patch adds support for destroying: - unicast DMAC control flow rules and - unicast DMAC with VLAN control flow rules, without affecting any other control flow rules, when HWS flow engine is used. Signed-off-by: Dariusz Sosnowski Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.h | 8 +++ drivers/net/mlx5/mlx5_flow_hw.c | 72 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw_stubs.c | 27 ++++++++++ 3 files changed, 107 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 2ff0b25d4d..165d17e40a 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2994,11 +2994,19 @@ int mlx5_flow_hw_ctrl_flows(struct rte_eth_dev *dev, uint32_t flags); /** Create a control flow rule for matching unicast DMAC (HWS). */ int mlx5_flow_hw_ctrl_flow_dmac(struct rte_eth_dev *dev, const struct rte_ether_addr *addr); +/** Destroy a control flow rule for matching unicast DMAC (HWS). */ +int mlx5_flow_hw_ctrl_flow_dmac_destroy(struct rte_eth_dev *dev, const struct rte_ether_addr *addr); + /** Create a control flow rule for matching unicast DMAC with VLAN (HWS). */ int mlx5_flow_hw_ctrl_flow_dmac_vlan(struct rte_eth_dev *dev, const struct rte_ether_addr *addr, const uint16_t vlan); +/** Destroy a control flow rule for matching unicast DMAC with VLAN (HWS). */ +int mlx5_flow_hw_ctrl_flow_dmac_vlan_destroy(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr, + const uint16_t vlan); + void mlx5_flow_hw_cleanup_ctrl_rx_templates(struct rte_eth_dev *dev); int mlx5_flow_group_to_table(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index d573cb5640..c017b64624 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -16209,6 +16209,41 @@ mlx5_flow_hw_ctrl_flow_dmac(struct rte_eth_dev *dev, addr, 0); } +int +mlx5_flow_hw_ctrl_flow_dmac_destroy(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_hw_ctrl_flow *entry; + struct mlx5_hw_ctrl_flow *tmp; + int ret; + + /* + * HWS does not have automatic RSS flow expansion, + * so each variant of the control flow rule is a separate entry in the list. + * In that case, the whole list must be traversed. + */ + entry = LIST_FIRST(&priv->hw_ctrl_flows); + while (entry != NULL) { + tmp = LIST_NEXT(entry, next); + + if (entry->info.type != MLX5_HW_CTRL_FLOW_TYPE_DEFAULT_RX_RSS_UNICAST_DMAC || + !rte_is_same_ether_addr(addr, &entry->info.uc.dmac)) { + entry = tmp; + continue; + } + + ret = flow_hw_destroy_ctrl_flow(dev, entry->flow); + LIST_REMOVE(entry, next); + mlx5_free(entry); + if (ret) + return ret; + + entry = tmp; + } + return 0; +} + int mlx5_flow_hw_ctrl_flow_dmac_vlan(struct rte_eth_dev *dev, const struct rte_ether_addr *addr, @@ -16218,6 +16253,43 @@ mlx5_flow_hw_ctrl_flow_dmac_vlan(struct rte_eth_dev *dev, addr, vlan); } +int +mlx5_flow_hw_ctrl_flow_dmac_vlan_destroy(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr, + const uint16_t vlan) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_hw_ctrl_flow *entry; + struct mlx5_hw_ctrl_flow *tmp; + int ret; + + /* + * HWS does not have automatic RSS flow expansion, + * so each variant of the control flow rule is a separate entry in the list. + * In that case, the whole list must be traversed. + */ + entry = LIST_FIRST(&priv->hw_ctrl_flows); + while (entry != NULL) { + tmp = LIST_NEXT(entry, next); + + if (entry->info.type != MLX5_HW_CTRL_FLOW_TYPE_DEFAULT_RX_RSS_UNICAST_DMAC_VLAN || + !rte_is_same_ether_addr(addr, &entry->info.uc.dmac) || + vlan != entry->info.uc.vlan) { + entry = tmp; + continue; + } + + ret = flow_hw_destroy_ctrl_flow(dev, entry->flow); + LIST_REMOVE(entry, next); + mlx5_free(entry); + if (ret) + return ret; + + entry = tmp; + } + return 0; +} + static __rte_always_inline uint32_t mlx5_reformat_domain_to_tbl_type(const struct rte_flow_indir_action_conf *domain) { diff --git a/drivers/net/mlx5/mlx5_flow_hw_stubs.c b/drivers/net/mlx5/mlx5_flow_hw_stubs.c index 985c046056..0e79e6c1f2 100644 --- a/drivers/net/mlx5/mlx5_flow_hw_stubs.c +++ b/drivers/net/mlx5/mlx5_flow_hw_stubs.c @@ -26,6 +26,19 @@ mlx5_flow_hw_ctrl_flow_dmac(struct rte_eth_dev *dev __rte_unused, return -rte_errno; } +/* + * This is a stub for the real implementation of this function in mlx5_flow_hw.c in case: + * - PMD is compiled on Windows or + * - available rdma-core does not support HWS. + */ +__rte_weak int +mlx5_flow_hw_ctrl_flow_dmac_destroy(struct rte_eth_dev *dev __rte_unused, + const struct rte_ether_addr *addr __rte_unused) +{ + rte_errno = ENOTSUP; + return -rte_errno; +} + /* * This is a stub for the real implementation of this function in mlx5_flow_hw.c in case: * - PMD is compiled on Windows or @@ -39,3 +52,17 @@ mlx5_flow_hw_ctrl_flow_dmac_vlan(struct rte_eth_dev *dev __rte_unused, rte_errno = ENOTSUP; return -rte_errno; } + +/* + * This is a stub for the real implementation of this function in mlx5_flow_hw.c in case: + * - PMD is compiled on Windows or + * - available rdma-core does not support HWS. + */ +__rte_weak int +mlx5_flow_hw_ctrl_flow_dmac_vlan_destroy(struct rte_eth_dev *dev __rte_unused, + const struct rte_ether_addr *addr __rte_unused, + const uint16_t vlan __rte_unused) +{ + rte_errno = ENOTSUP; + return -rte_errno; +} -- 2.39.5