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 30FF945B5A; Thu, 17 Oct 2024 09:59:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FA6F4067C; Thu, 17 Oct 2024 09:58:38 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062.outbound.protection.outlook.com [40.107.220.62]) by mails.dpdk.org (Postfix) with ESMTP id BE54D406B4 for ; Thu, 17 Oct 2024 09:58:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=REzfufanP57z0qcf2qZH1+r8Qqr3nasC6GIp8IkGjjw08evOXRCTvX7a0rNCNjTpnofCq9Qjxogxc+uPcKZRG3e8fQW0sgJcXcth56ASpQQDTI7LyyVBrmR2H5tgLy5VAXvEs0AKtVRerEvm5G96i1hz53U6LZ/KcT29u8sa/Y22C8wUemEh0fbA/zcakGjgr9rR1ZFEsDH76xIR0BjhrgLsXaQ4wuN9hhozdkF0b+HO56LtyaGiHdMwGnLBaVCeMUvvC2ILQZ9qnQoXItuEa55sZo+PpwluHPUKVDFIs/FRpruJIHh2W6wzGjVHqLQSdw9ARVoR1YlX0bMoKPTEQg== 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=CYAyC83vcs3arr1DppjFboJ5iTSN9fYInXn/6hhFuDs=; b=cuj4Sw+i5gph+gySJBkZqoSkwJ5guOlEJxoDHbUpivD18R0q22R5/wSuHSH1rpGLmFTBgN/JMBedQ3be6T/6tl85lu+2wi9ywWrZJajG7Ryp45yiPl1rV7Y68fptlGqbsWi4+wL7VCkWep6KHNpb+ObM3C1uepHyeCWuFqvGXLkS3rzwEOQ41IeSPnK1eixBsJnU4iHEZzHnjTNRi6ZeSjCU34tm3nIchuehBoDSE718lUkWKvpgOJoiOiPnTM5j7DfQEWa4xC5IyF7Mhb9C1s5iZ99aiV1vv/TBkloUlv0ZD/gpIpffeelOTCI2312O9ZcN2HKXOT6O6abM6SP/IA== 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=CYAyC83vcs3arr1DppjFboJ5iTSN9fYInXn/6hhFuDs=; b=E8x+3i0r4frziEonAqxAQgs+sgC2ah0y/QIPDbKM7Fgefaxmbs9eRBVROKXXNQ6c+Nv61y1tK/fOvycFNAnDAFeKweN6wjqp3aki9CsBusBOARti1UvZn3IrBhLEDntKpIvWAtJzi5Ee/Gmv9elspHFZ0iErxr1jt+GsMEnz/pcGL65BMw93d2vAZvw+dm8lwgOBjFayCHmIVYZQXPzf+gWfgp+FUQh7TGcITJeaq/t1c+nmqUCxuedZu5vA2BAoIYsWMkKvlkcgD7qVB/RcIzuDGgVM3d+aYI5YiWFiUhA9SUBP8L5OZYbCDFoJWJ8ijKEXEyGd1LMtmf2jRZpLJw== Received: from BL0PR02CA0003.namprd02.prod.outlook.com (2603:10b6:207:3c::16) by PH0PR12MB7791.namprd12.prod.outlook.com (2603:10b6:510:280::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Thu, 17 Oct 2024 07:58:33 +0000 Received: from MN1PEPF0000F0DE.namprd04.prod.outlook.com (2603:10b6:207:3c:cafe::3e) by BL0PR02CA0003.outlook.office365.com (2603:10b6:207:3c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 07:58:33 +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 MN1PEPF0000F0DE.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 07:58:33 +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; Thu, 17 Oct 2024 00:58:15 -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; Thu, 17 Oct 2024 00:58:13 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 07/10] net/mlx5: add legacy unicast flow rules management Date: Thu, 17 Oct 2024 09:57:35 +0200 Message-ID: <20241017075738.190064-8-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241017075738.190064-1-dsosnowski@nvidia.com> References: <20241017075738.190064-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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0DE:EE_|PH0PR12MB7791:EE_ X-MS-Office365-Filtering-Correlation-Id: 1934c63b-71be-4f60-6f71-08dcee817f32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Yk91/6QEPHVJLQzLlIXMDo48bjEGWiqyZFQ0yUADIusPDDCl/i8BjDF3fafE?= =?us-ascii?Q?wjY9yu6iUECSE3WUmEUBRfZMyqjKcNwCaK/OdC5d9pqLlKrxnrkOrEQwYlaA?= =?us-ascii?Q?CbPi++YPasoZt7cS/WQYdbZSJKTuCf2OaYDmmv2j3yc7uapp2fJFlGpKcR5b?= =?us-ascii?Q?ItETkCBtToPzxQ2WeZz8mPXNj56wWQXDHxdSun40B3Jcr/dCeIrdaSxgDjp7?= =?us-ascii?Q?BsWhWCoEDa6isP34W9katS73kYF94hDi03JpcD9iFx4JoCKu64cxVhD3wuYg?= =?us-ascii?Q?2mtOwRz39W4AneWG1oftz9ZyUTF9KRR4vMzRKWaoU1crxiccj2rmbPsilnMS?= =?us-ascii?Q?mUwG32VaEE8ge57Q9aHueuZtwgsmqeldrhOVSimv4PkzN05UR2Q2Nc9GBsQc?= =?us-ascii?Q?6oyFvw/vDDRSsWG8r8j7vX+fF0kpBknf6PcrqjSahc/brbQqi3UrYk76PDVV?= =?us-ascii?Q?TyNunZk0Bz96tLNaatXMJ+5kKfhzFmhiU914wvNyShw5/ss4UYGE3rjVmeJS?= =?us-ascii?Q?dC6j+TCQiHLOAl//AIsNl5uMvftRsFANvw3jB3QXa68MdchFhdWdXXPWfi5Y?= =?us-ascii?Q?IaQ1h6+rbnkgRIypcgT8EAO4LGc/CbLeMpF8t67MoF6U/U4J5UEjYY24iNtF?= =?us-ascii?Q?Wbvxm3SUz1/gZSZkY4dyGlF42ZH6kor4VBkqCSME4yKfpIUPec4udVs7s7mV?= =?us-ascii?Q?lWowYk60+7+5w0H4Ol9orY+3AlfGUOE23jq5hG5TZETETp4GyZPuiNkDf8td?= =?us-ascii?Q?J9NS8ImdLJ5X3DlhnyBbNaNVXfsWJQamvA1zFdDUZws9kZZd4Ov799v5mT8c?= =?us-ascii?Q?QS2gjfRcAcL6Vm7CnVjm61xLFQdYOMmvlEdZQHmMHbH5IfwBF1qzhtPlKSfv?= =?us-ascii?Q?XDzt1Eg1DkgHHc0OhrTzUr+Zwp1a/WpSNpJsZeLlf59t6xWYCKhWdpQVuATx?= =?us-ascii?Q?PDBKRqW5PH4DslWnEz/xtM6SfuO9r4tHWXMjNWzR0WrT1fUyi7W7BNX318VQ?= =?us-ascii?Q?fTvPHBLv//dltavmBCigMXPmPVe1AUdGgPSTEIvyKtgkqkMi5PMi++G26qlV?= =?us-ascii?Q?7wSkVDsz9TUe6cUdYp+0iRQ38xIv/Jfh8qSIuuaG4T2rtEEzNwGt8AcyofBG?= =?us-ascii?Q?043g6VrF9DTn78oNlLeSjEDMr0iPddvAK14TIEU1lyRV3nrehoFKCgJU6B75?= =?us-ascii?Q?wJv7kyIT9zNu01CtwjA5SOwPmGeyRXIk/EOFqJgQ0kYef04zWuh/OWsQFyoz?= =?us-ascii?Q?VMDAjnWPPGFjercmwXzQy8nXKkun/77tA7e/I+ROqwH7PLhPPWZ5yDXDONnP?= =?us-ascii?Q?bvDBClFg6v9mjp/zuwqwhXkEFVovAhDwfXmja7jmjM44hxOI31wv+2pvAkRn?= =?us-ascii?Q?uIEHRasvZGtqSZ8q97e8EjlBam+K22jQYuu6PKX6pSlhhq4alw=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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 07:58:33.0096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1934c63b-71be-4f60-6f71-08dcee817f32 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: MN1PEPF0000F0DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7791 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 the following internal functions for creation of unicast DMAC flow rules: - mlx5_legacy_dmac_flow_create() - simple wrapper over mlx5_ctrl_flow(). - mlx5_legacy_dmac_vlan_flow_create() - simple wrapper over mlx5_ctrl_flow_vlan(). These will be used as a basis for implementing dynamic additions of unicast DMAC or unicast DMAC with VLAN control flow rules when new addresses/VLANs are added. Also, this path adds the following internal functions for destructions of unicast DMAC flow rules: - mlx5_legacy_ctrl_flow_destroy() - assuming a flow rule is on the control flow rule list, destroy it. - mlx5_legacy_dmac_flow_destroy() - find and destroy a flow rule with given unicast DMAC. - mlx5_legacy_dmac_flow_destroy() - find and destroy a flow rule with given unicast DMAC and VLAN ID. These will be used as a basis for implementing dynamic removals of unicast DMAC or unicast DMAC with VLAN control flow rules when addresses/VLANs are removed. At the moment, no relevant flow rules are registered on the list when working with Verbs or DV flow engine. This will be added in the follow up commit. Signed-off-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_flow.c | 80 ++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 19 +++++++++ 2 files changed, 99 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index af79956eaa..463edae70e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -8534,6 +8534,86 @@ mlx5_ctrl_flow(struct rte_eth_dev *dev, return mlx5_ctrl_flow_vlan(dev, eth_spec, eth_mask, NULL, NULL); } +int +mlx5_legacy_dmac_flow_create(struct rte_eth_dev *dev, const struct rte_ether_addr *addr) +{ + struct rte_flow_item_eth unicast = { + .hdr.dst_addr = *addr, + }; + struct rte_flow_item_eth unicast_mask = { + .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + }; + + return mlx5_ctrl_flow(dev, &unicast, &unicast_mask); +} + +int +mlx5_legacy_dmac_vlan_flow_create(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr, + const uint16_t vid) +{ + struct rte_flow_item_eth unicast_spec = { + .hdr.dst_addr = *addr, + }; + struct rte_flow_item_eth unicast_mask = { + .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + }; + struct rte_flow_item_vlan vlan_spec = { + .hdr.vlan_tci = rte_cpu_to_be_16(vid), + }; + struct rte_flow_item_vlan vlan_mask = rte_flow_item_vlan_mask; + + return mlx5_ctrl_flow_vlan(dev, &unicast_spec, &unicast_mask, &vlan_spec, &vlan_mask); +} + +void +mlx5_legacy_ctrl_flow_destroy(struct rte_eth_dev *dev, struct mlx5_ctrl_flow_entry *entry) +{ + uintptr_t flow_idx; + + flow_idx = (uintptr_t)entry->flow; + mlx5_flow_list_destroy(dev, MLX5_FLOW_TYPE_CTL, flow_idx); + LIST_REMOVE(entry, next); + mlx5_free(entry); +} + +int +mlx5_legacy_dmac_flow_destroy(struct rte_eth_dev *dev, const struct rte_ether_addr *addr) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_ctrl_flow_entry *entry; + + LIST_FOREACH(entry, &priv->hw_ctrl_flows, next) { + if (entry->info.type != MLX5_CTRL_FLOW_TYPE_DEFAULT_RX_RSS_UNICAST_DMAC || + !rte_is_same_ether_addr(addr, &entry->info.uc.dmac)) + continue; + + mlx5_legacy_ctrl_flow_destroy(dev, entry); + return 0; + } + return 0; +} + +int +mlx5_legacy_dmac_vlan_flow_destroy(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr, + const uint16_t vid) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_ctrl_flow_entry *entry; + + LIST_FOREACH(entry, &priv->hw_ctrl_flows, next) { + if (entry->info.type != MLX5_CTRL_FLOW_TYPE_DEFAULT_RX_RSS_UNICAST_DMAC_VLAN || + !rte_is_same_ether_addr(addr, &entry->info.uc.dmac) || + vid != entry->info.uc.vlan) + continue; + + mlx5_legacy_ctrl_flow_destroy(dev, entry); + return 0; + } + return 0; +} + /** * Create default miss flow rule matching lacp traffic * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 165d17e40a..db56ae051d 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2991,6 +2991,25 @@ struct mlx5_flow_hw_ctrl_fdb { int mlx5_flow_hw_ctrl_flows(struct rte_eth_dev *dev, uint32_t flags); +/** Create a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */ +int mlx5_legacy_dmac_flow_create(struct rte_eth_dev *dev, const struct rte_ether_addr *addr); + +/** Destroy a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */ +int mlx5_legacy_dmac_flow_destroy(struct rte_eth_dev *dev, const struct rte_ether_addr *addr); + +/** Create a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */ +int mlx5_legacy_dmac_vlan_flow_create(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr, + const uint16_t vid); + +/** Destroy a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */ +int mlx5_legacy_dmac_vlan_flow_destroy(struct rte_eth_dev *dev, + const struct rte_ether_addr *addr, + const uint16_t vid); + +/** Destroy a control flow rule registered on port level control flow rule type. */ +void mlx5_legacy_ctrl_flow_destroy(struct rte_eth_dev *dev, struct mlx5_ctrl_flow_entry *entry); + /** 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); -- 2.39.5