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 AC83A45BA0; Tue, 22 Oct 2024 14:08:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4259F406BC; Tue, 22 Oct 2024 14:07:38 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) by mails.dpdk.org (Postfix) with ESMTP id C6AA34065E for ; Tue, 22 Oct 2024 14:07:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rIqpXSEXCq0wPEO0NtLCWaOPbtdTzcq3ewrT5UkX4EjKeh77PGNVOe0NeW3b08nQujWxsiJCGOzQBmiWqwPTjG1psxkWNh7ifwwbJbAGuVc9LgDwirFXSyKXabKouWFz8yZ6WO3u5dAJkceMtL9OcHP461l0KYXp9mqPPUF7B5bHf2kdqC3XSNfaRwg7N+NdRaVJBtdSqZz5lZTx9NJyy9y1QTr8l/YqAn9VtOwGMxvHCY0aAysZWvHPOg0ZWEBUEKSRKXP+sZv79Sqjr/3MPyn5bB0Sc5TCDoM3ApV9M5HDEYEb2lhiv72+9NAHMYldQOPoDYHFA9vVC4J48+c/Hw== 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=NqOTHkgsCFGQVIP7YWBJLiCdd34lK/AvG9v+0jgZg/I=; b=bJP2Sy8EacHKDsoHZg82i47gjI/8uV/rE8KOII3cZRkCuDbM0Vhg8VK4du+V+keQi1QlpQC/9KNtHJTIso+NM/pbNzMhrK0OMdRyxOWCllVaXthnRc76065pmaEURs0iO7DNwA9cLR91unqoEBNOqBKyvz4fnTolXBr3MT9iW4Ndb4v4UWmqp+2IsScvITxjXhch40HhqGRzOBKTSPk0PF+tEZjNOJgi7EqOCq/EfrlQeH7CTQYMzO/n/C8bP7aYUhMkT8qN5FIWIs6rjXqNtNOEa+LNM+5TPtFbxHiIkKpMCietnIwR4IYnKabqPX9KjpNvPXtPODzgkgZQbxmijA== 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=NqOTHkgsCFGQVIP7YWBJLiCdd34lK/AvG9v+0jgZg/I=; b=cGSc8ZpAUDBeBJrBGvkYdikpLaJIuVlv7JUm14H/WGdLkVmav+WyaKnm/ZVTVBKGs6BYSfsRQyq69Ikf3LLbVl5dAvXqSrchF+P4EJvphfO424vK9Auu3uJa9FWeaRtOoiPqnRnPbRn8joLCUCnSj507cqU31Ko468v4MW4eeNQ9x/qCJEJLAIrVkrPQjVM4Mg2g6AJbyZoOxQ5F0ZAE3rVJabYBcc346GCW0bhJbOtHkb/yAO9FlZb5XiD/geDDcyNuyOULqRk3i+S6q+JZMwN8R4QEWmHnzzO87ZGGf/YHeH/EFeV2v8WHP8JCUjmAEV2+nUzXclSBkOBKWMnlhQ== Received: from SJ0PR13CA0142.namprd13.prod.outlook.com (2603:10b6:a03:2c6::27) by CH3PR12MB8257.namprd12.prod.outlook.com (2603:10b6:610:121::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 12:07:26 +0000 Received: from SJ1PEPF000023D9.namprd21.prod.outlook.com (2603:10b6:a03:2c6:cafe::67) by SJ0PR13CA0142.outlook.office365.com (2603:10b6:a03:2c6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 12:07:25 +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 SJ1PEPF000023D9.mail.protection.outlook.com (10.167.244.74) 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:25 +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:07:12 -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:10 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 10/10] net/mlx5: optimize MAC address and VLAN filter handling Date: Tue, 22 Oct 2024 14:06:18 +0200 Message-ID: <20241022120618.512091-11-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: SJ1PEPF000023D9:EE_|CH3PR12MB8257:EE_ X-MS-Office365-Filtering-Correlation-Id: dee3f900-c99d-4479-62c1-08dcf29217b5 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?eusu+kuJwE3UcVJyjNOMFYCjqkssOW7wckeaZY7ZGOas1kWZmmErc33u6Qn1?= =?us-ascii?Q?XX+lG+ibK+KmZH+J8TXMINRmeRh8E8ZyuTCxYTog/z6r71+Nf9vDU659EN9V?= =?us-ascii?Q?gXwfODRo1dcX3A3UpDlHimiSOMOBpkM8q5yLWnQuws8xi4oFJaNp/WM8KOGz?= =?us-ascii?Q?kKXSvLbQnkZX8jgzPccUrxg5rc4Jj9+t1L8Ebg5Kgq+Xvc6K8GWCISN+eq8r?= =?us-ascii?Q?DdxQcLQy3U5CJcuG9JAra6B2jZtFcDxSjc1juxM2Lgtr1d/NDU7V/cDGRMoR?= =?us-ascii?Q?OamapQLmTOsXj7ztLVp485UjYMrW/LAgGqul1dOFf4kXXYVcjpTGlxydmL7W?= =?us-ascii?Q?BNMR2njgbyV7RNJXZ6/jUTyLsWrlD01QCfPSwl5UFA0NTGo8UAmwLMR7rFPj?= =?us-ascii?Q?dJEUvxTXnfgO1D98FwZKz9EoxtrTqETjWAxwSLF1LOZEDaxwfesHJ9DLomBu?= =?us-ascii?Q?DZxNl5spT+4c9XRG2zjpnFq1IqZKkQ7BK/0qvik5LxA5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f2EZlN1VJjJEznRn6QxiXbARKtCL99Xqg7nfBbw=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:25.5428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dee3f900-c99d-4479-62c1-08dcf29217b5 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: SJ1PEPF000023D9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8257 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 Acked-by: Viacheslav Ovsiienko --- 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