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 37A4145B5A; Thu, 17 Oct 2024 09:59:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E60040A6D; Thu, 17 Oct 2024 09:58:43 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2051.outbound.protection.outlook.com [40.107.101.51]) by mails.dpdk.org (Postfix) with ESMTP id 5D98140697 for ; Thu, 17 Oct 2024 09:58:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JV9rNluIps8NRP5DOxsjAXhulldlkkmJebAxQxVPXf3XgJ6nTTKy/rMdEyYGnktHazfjtIhmImR6yFO7nXLr7ObNxY8+dAh3X9v15uJ+tJJdMDw7RQXkHSF33lWuJ1K+/i/h06qyykDDK4nWbc0yqsEJw4NYhbhP8uZNL8B7VinCW1Xzp0oYqenZNrpFxhy1DWmTlxXliOD8CJ8Wg9YmX3MZJ/hJHGv1tDXW5/A/zZ0RkfnFxzNKUiO5M4UViNBe/NHK5xDHBUwToSkrc7gHIHY1oN9y5r/Jt37rYZOzc18wJA2TsKLcSBE9+ArKTHNOfReKt+akS/2IY0EMyK9WVA== 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=x2PbaVDjyn+DNfG1r8Ux34FnYdTIhaTiSLRcb8WdVok=; b=USAbzZgMvnQHcGgE6JX7zfFxYFcJ5WqpsmlA3M9LWKu47tmr91KnGD17nuYOxCAADDoZV8szaGlVCcajsoh5MI5oMcXeQyzf18q5qQ49nNClSuj9Vbi8wo4688tixgqkqrbd470/ANuiVSG/IuFDtXDwzbmfjmrDIquRRTwBznUZucmI+GllBqS8PDPS/5Sl2Uk2JUMsudbe0C8wALTW/eCa/erdheWJdCITgEHiL/JxRXT7Th5qKVMmfgH9mu6dK9CGfdgzyJiyZ/imTTOe4y6V9QUoboaFGMnCBJQ/ONcQvNlQzbpiGIs2nQl0mSwNFjdzOXQPAWTHSClpx22mhg== 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=x2PbaVDjyn+DNfG1r8Ux34FnYdTIhaTiSLRcb8WdVok=; b=Rz4Y7dvk7xIqbtYkcEmnkGIhgZwgismoZ3RiQrJaT8TBr9fZ9tFZS/lzy9FgdIkzC2ootYbW+PJ5o26nhUru4wDfDzeDfIw7Mt3QDfzt+Il+2qOYYpxrlkCMi2+0vSyw/+50N7JoH3YSSX60fz8iB+0gIEw9oQqIruyIEIUJGhBoOLOSUU1IHQPwiYm1L5i+Vv3w4GQC5ljQfXLZ4F2sTOZ94NJ1d6FDrI/gUCZB0QCx7XHL1i1h03sYiC/9ok1UknwnvdKtipVIEEjXbJV+oEIf7njU7cvBqc6Rs0fl2OKBh48AGdhdOaYWzivNNLkiS98QOHviB5KDA8RkN5fs6Q== Received: from SA1PR05CA0016.namprd05.prod.outlook.com (2603:10b6:806:2d2::25) by DS0PR12MB7772.namprd12.prod.outlook.com (2603:10b6:8:138::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 07:58:35 +0000 Received: from SA2PEPF000015CC.namprd03.prod.outlook.com (2603:10b6:806:2d2:cafe::ef) by SA1PR05CA0016.outlook.office365.com (2603:10b6:806:2d2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.8 via Frontend Transport; Thu, 17 Oct 2024 07:58:34 +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 SA2PEPF000015CC.mail.protection.outlook.com (10.167.241.202) 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:34 +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; Thu, 17 Oct 2024 00:58:22 -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:20 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 10/10] net/mlx5: optimize MAC address and VLAN filter handling Date: Thu, 17 Oct 2024 09:57:38 +0200 Message-ID: <20241017075738.190064-11-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: SA2PEPF000015CC:EE_|DS0PR12MB7772:EE_ X-MS-Office365-Filtering-Correlation-Id: a7fa0f3e-2072-412c-61fb-08dcee81803a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jZV4ovgDXCM8pt7WUS2cGCQGHl9tM/A8V8iWx15ORBu6kdpl7cgzYSgAC6Ey?= =?us-ascii?Q?jGbCoDPmVp/U8tqe5dnlSHBjHfkX8RbxHGgHCmkahSyxxjQWu3FSt4r0E7+a?= =?us-ascii?Q?jjoa1O8iGcbhrrbfS51pAqxM0Lep6ThRHRtX6YsQhYvWA0+V0MD1X6xuXQnq?= =?us-ascii?Q?IkUyQG1lcwrn73rKSbTIJj+k0XuNOQZx2Et7TYlNOzLL3rJBeH/rm08+WTUo?= =?us-ascii?Q?I7zcPaybSlpuakMaHrjD76l707EtAquk3QCas9gsaRAuimGsFORSHP+nZjT/?= =?us-ascii?Q?+rDIK08LgCXZ1Yd8JAVfKZLNu02UY3W5/mJp4+VMO/B3izHDk7aRUgOYj2Yx?= =?us-ascii?Q?c6YiYKFJ0S1e7VEjHUv6V07NY096xjaAYUOFw5Kq4bdxKdP/2cvgo2WGPawR?= =?us-ascii?Q?ighGkEuk3VnriGa1mCMuZRU3syhX8qxd6Illn3rg3EekNrTACwtwOFJxQbrJ?= =?us-ascii?Q?eyHibxGy/7OP1u0/NX3LCOA8oPEo5R29bMDcEheb2wXHCjOq3CuW3kky3hc6?= =?us-ascii?Q?E59Rr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EjunEhA=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)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 07:58:34.8019 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7fa0f3e-2072-412c-61fb-08dcee81803a 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: SA2PEPF000015CC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7772 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: - Changes MAC address adding/removing handling, so that only required control rules are added/removed. As a result, rte_eth_dev_mac_addr_add() or rte_eth_dev_mac_addr_remove() calls are faster for mlx5 PMD. - Changes VLAN filtering handling, so that only required control flow rules are added/removed. As a result, rte_eth_dev_vlan_filter() call is faster for mlx5 PMD. Signed-off-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_mac.c | 41 +++++++++++++++++++++++++----------- drivers/net/mlx5/mlx5_vlan.c | 9 ++++---- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c index 22a756a52b..0e5d2be530 100644 --- a/drivers/net/mlx5/mlx5_mac.c +++ b/drivers/net/mlx5/mlx5_mac.c @@ -25,15 +25,25 @@ * Pointer to Ethernet device structure. * @param index * MAC address index. + * @param addr + * If MAC address is actually removed, it will be stored here if pointer is not a NULL. + * + * @return + * True if there was a MAC address under given index. */ -static void -mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) +static bool +mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev, + uint32_t index, + struct rte_ether_addr *addr) { MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); if (rte_is_zero_ether_addr(&dev->data->mac_addrs[index])) - return; + return false; mlx5_os_mac_addr_remove(dev, index); + if (addr != NULL) + *addr = dev->data->mac_addrs[index]; memset(&dev->data->mac_addrs[index], 0, sizeof(struct rte_ether_addr)); + return true; } /** @@ -91,15 +101,15 @@ mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) { + struct rte_ether_addr addr = { 0 }; int ret; if (index >= MLX5_MAX_UC_MAC_ADDRESSES) return; - mlx5_internal_mac_addr_remove(dev, index); - if (!dev->data->promiscuous) { - ret = mlx5_traffic_restart(dev); + if (mlx5_internal_mac_addr_remove(dev, index, &addr)) { + ret = mlx5_traffic_mac_remove(dev, &addr); if (ret) - DRV_LOG(ERR, "port %u cannot restart traffic: %s", + DRV_LOG(ERR, "port %u cannot update control flow rules: %s", dev->data->port_id, strerror(rte_errno)); } } @@ -132,9 +142,7 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, ret = mlx5_internal_mac_addr_add(dev, mac, index); if (ret < 0) return ret; - if (!dev->data->promiscuous) - return mlx5_traffic_restart(dev); - return 0; + return mlx5_traffic_mac_add(dev, mac); } /** @@ -154,6 +162,12 @@ mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) uint16_t port_id; struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_priv *pf_priv; + struct rte_ether_addr old_mac_addr = dev->data->mac_addrs[0]; + int ret; + + /* ethdev does not check if new default address is the same as the old one. */ + if (rte_is_same_ether_addr(mac_addr, &old_mac_addr)) + return 0; /* * Configuring the VF instead of its representor, @@ -188,7 +202,10 @@ mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) DRV_LOG(DEBUG, "port %u setting primary MAC address", dev->data->port_id); - return mlx5_mac_addr_add(dev, mac_addr, 0, 0); + ret = mlx5_mac_addr_add(dev, mac_addr, 0, 0); + if (ret) + return ret; + return mlx5_traffic_mac_remove(dev, &old_mac_addr); } /** @@ -208,7 +225,7 @@ mlx5_set_mc_addr_list(struct rte_eth_dev *dev, return -rte_errno; } for (i = MLX5_MAX_UC_MAC_ADDRESSES; i != MLX5_MAX_MAC_ADDRESSES; ++i) - mlx5_internal_mac_addr_remove(dev, i); + mlx5_internal_mac_addr_remove(dev, i, NULL); i = MLX5_MAX_UC_MAC_ADDRESSES; while (nb_mc_addr--) { ret = mlx5_internal_mac_addr_add(dev, mc_addr_set++, i++); diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c index e7161b66fe..43a314a679 100644 --- a/drivers/net/mlx5/mlx5_vlan.c +++ b/drivers/net/mlx5/mlx5_vlan.c @@ -54,7 +54,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) MLX5_ASSERT(priv->vlan_filter_n != 0); /* Enabling an existing VLAN filter has no effect. */ if (on) - goto out; + goto no_effect; /* Remove VLAN filter from list. */ --priv->vlan_filter_n; memmove(&priv->vlan_filter[i], @@ -66,14 +66,13 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) MLX5_ASSERT(i == priv->vlan_filter_n); /* Disabling an unknown VLAN filter has no effect. */ if (!on) - goto out; + goto no_effect; /* Add new VLAN filter. */ priv->vlan_filter[priv->vlan_filter_n] = vlan_id; ++priv->vlan_filter_n; } -out: - if (dev->data->dev_started) - return mlx5_traffic_restart(dev); + return on ? mlx5_traffic_vlan_add(dev, vlan_id) : mlx5_traffic_vlan_remove(dev, vlan_id); +no_effect: return 0; } -- 2.39.5