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 2E56E45BA0; Tue, 22 Oct 2024 14:08:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 894B7406A2; Tue, 22 Oct 2024 14:07:50 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2070.outbound.protection.outlook.com [40.107.243.70]) by mails.dpdk.org (Postfix) with ESMTP id 4FC73406B6 for ; Tue, 22 Oct 2024 14:07:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mgF8gKU2tOzUOHST2eJLJ3iWZ3mbhUdD3l5Ar/Iv+m4iOUhtxB0s5ahw9nLvZszU93jMAP0r0b54Va9tFDlNjGkHx/THIupvUtQ7FtYUSyUE/j7zGvbLjljihbtcAEllW+mfxGIQ0l6bXb5hxq5e/B0ocZ42DJsnYK0RSJPBge+SsRMrFO10RBSV4eb4NVtBDLrdJExuFfkNfSSqDQOtg7ZVPyoaoI5KV4rdYQYl4mCQEouXN9OJ3WfcYAWGdF3a3fd5xNFq0vNyaDo8iu30afGAHYr4uMh13UEPGe8Lx94kVixiwx5KZWJqYKmeMiPT+jwWjnOuK+7W6RuStniKfQ== 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=yX3gug3hty9JagxiqsCHkqOJBDHwqxm3AnAORZbWYFs=; b=h4u2wQNN1WGC5zeiasuvz5S+BkdhCBfxbU9yRUUgr+tvmoEDH0sDRVqmACnIi4SaK39k4ssdk30hbGC9cZIwEJWpG2roFiMgQP2eTZlhsEYwCbOixWq3JyhBtK2l5Lzr8Q41DYGtXnkLzQvQj26dn43bF1PxLKaGyuX6WBrTcKZC5S12L+hVN9zVmRMdXmTmMu3C6CCeSNTluTEp1aspDtw3INkrNYgECNIlhrkDGKTq3lRS71tBfTIoaMUWYap6VadIccaJclvZlv3+bJYRV9uQns+4TLLUhdQJaK+tM7NRPAdn/8i/fgiTj7YsJ+mGjvwrY6nG39c6HIe5m5pBDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=yX3gug3hty9JagxiqsCHkqOJBDHwqxm3AnAORZbWYFs=; b=TT9AEOjANT2JOKGwaKZwZOSEUZO4+mI3UoXgRgxuCVV/tDXrnwsCiITuYSKEPiaYKTSGaywK7k/jMxhj+Hicc0RGPyhWEN40RrXx9DoxcEnDImynDFFnmtEP4GuCCDtH58+vTlRgWbtrqm67n25pXK7z/e9URyIePbVg9BzWlqFAUmNAJjjaXosOt2DBpN+IVmV0rWKl2Sp/jA/2Kc73MqXhncM/yigO+abwsyDnPdRuVia6iW+9wxbeO9q+/5bIMwIFDSezW7hjn9QDnJYwuydU5uGYhrB3OlM06HlToJ2JY2Gici5qzdscEPWDs9ulXx7sLEyhWrjvP5Nry7dhHA== Received: from BLAPR03CA0131.namprd03.prod.outlook.com (2603:10b6:208:32e::16) by PH7PR12MB7818.namprd12.prod.outlook.com (2603:10b6:510:269::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Tue, 22 Oct 2024 12:07:29 +0000 Received: from BN1PEPF00006001.namprd05.prod.outlook.com (2603:10b6:208:32e:cafe::a6) by BLAPR03CA0131.outlook.office365.com (2603:10b6:208:32e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 12:07:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN1PEPF00006001.mail.protection.outlook.com (10.167.243.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 12:07:28 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) 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:07:05 -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:07:03 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 07/10] net/mlx5: add legacy unicast flow rules management Date: Tue, 22 Oct 2024 14:06:15 +0200 Message-ID: <20241022120618.512091-8-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: BN1PEPF00006001:EE_|PH7PR12MB7818:EE_ X-MS-Office365-Filtering-Correlation-Id: 2306efef-e014-45f0-ebee-08dcf29219c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lF+nTQt5YYolYd41rlQ8aFfhyoX5UQhkFi7i0bpkpnDqWgromStxOemTBxUW?= =?us-ascii?Q?4b2w0Jy91bpfM8v41RGvrelbNZI10VK8jREPzN7qEjgUsdKmzTQFpyzi0nET?= =?us-ascii?Q?gmuW6YkPMRI6xDMTgB+lArRGZ/EaOkhDgaAtJNmFqvo+SJAnk1diTM4/luYh?= =?us-ascii?Q?6mGd4h8jUGkyGFgjAJjeOQud46nMnEKVXTlPh0jNjWDPW9mCf7oQveLOuiaj?= =?us-ascii?Q?8JPWtaaHm/41Q7GpwSxDh2AvkREfgyCbNcHdsvWPXaVg0deClLpyk3x8ItnE?= =?us-ascii?Q?awyhmev4ezOQ3mjI4bKsqoS31kxaZSCEPVlFZYrNtvWRwO7f+BQfoqOb3D80?= =?us-ascii?Q?mWrqrQncqRTOm+7VDvKb/4bOHrtXA3Xq2chHG3M8ZgGdwLH/mgtwcPNQQaAX?= =?us-ascii?Q?TvugvssZ0K4+rTVP8sR6rC8Ilppqitwk1EvBG4CYI6zEBg+Y6JaJzRWyWhd8?= =?us-ascii?Q?LKNI89XtzCMxbPkoP/F7eWj9+RXJYX0GTBK1in9+99VDOc8ShjUJyEVQa+IU?= =?us-ascii?Q?m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pjpUohuFPxPEQ=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 12:07:28.9506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2306efef-e014-45f0-ebee-08dcf29219c6 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00006001.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7818 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 Acked-by: Viacheslav Ovsiienko --- 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 62e3bca2f0..0d83357eb0 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -8532,6 +8532,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