From patchwork Tue Dec 14 10:21:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12675747 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79276C433F5 for ; Tue, 14 Dec 2021 10:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233032AbhLNKWU (ORCPT ); Tue, 14 Dec 2021 05:22:20 -0500 Received: from mail-mw2nam12on2077.outbound.protection.outlook.com ([40.107.244.77]:26272 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233037AbhLNKWN (ORCPT ); Tue, 14 Dec 2021 05:22:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7YM+Ag6l/FGFEGkzajxaRbC6/FPv4rQulQnQUSSwhXUF2sxGRT3gDpUGYpHzDtoKURcCi5ijkd9//zQMVDeiiREKkzOLpRR6cOs7MnUPoE4Ul/Qd7UZwkrLo0iNLW5LdoTLiqh8ocrZOaPwOuzjL7/uO4x8ayY4mhk3i6ZxzcZgztFmi0ZSiN5mYs/re4Cbrz2SsqVSwHXZ+sxrAprI7fStJyojklg1ggMpQW3ktaExWCSnL4fSEVIPcv708aeZnCqPzZFVCcISghmp/pBE/AueEcSoP9AtTO+nLuH5dSPrgxw5gE/jP8jCYxPRwz0lkuPc+dti3/+B53tAePjSBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=nS+iugIAWKcB5wbrznom4AYqCfvJLsVrQM9jknQTAvE=; b=h7sucQdwENI/XGJTUlCG0PGnJf863CQIIWRFGY4Jghwzo1b6/lju4POEgldV/YIGZeqnhWvL/+iHt42Ovw7JIuBfh+IcLwlHOChTT/M69EyQqikrTj1c/zDBs0dugM02dYXE37gnrKhvFwZkzC4KmNRGWU+KFIgzSrGospAO+E+A3purKnM/kpOJZmgXUg6JyWDi8Yvvyf1kPg/OziaYITLyr9wd5KX7XCeoHjK5+2rgGAvEI74CX8nYuM51in59jFi5tKov/c6xJ5kHhXo2tbl5vw9JtVTcGPT4aRVLsnQizqd12anG72E8lzHZRMzCOvQVw6OewDV/tny4URjJ3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none 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=nS+iugIAWKcB5wbrznom4AYqCfvJLsVrQM9jknQTAvE=; b=e7efdw/zUHOccEXKrfXQEZrt7zHno+mhPrSSxso9WqTgRPxZydxRwZRk2mfwiNlzjhM/QspHF0BAZgBgKZ3GJGZiPpZOH/jhVz33/P/PjNKYBhDcjKB9FwBI68DMrOi22fZdX/6qK7GKZV51wQ879mYEeaslfTkO3VhQoZroGL4VtjJ1+PeIXLY0EOAsRoV68NqkdRzDm13rje2QMPYTRnkXow0VOqIOVw7ydo4ukR6wFE1MJDgIk9NAudcqG8ptsHevT7qX9S4OvSQY/w7Yhb4TBk44HlsqMFZ9mb9uQllzYAImRvoEkOOvW1Fm0avOMvmmsCqMer2Q07FC/5q4fw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) by BYAPR12MB3079.namprd12.prod.outlook.com (2603:10b6:a03:a9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.11; Tue, 14 Dec 2021 10:22:10 +0000 Received: from BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b]) by BYAPR12MB4757.namprd12.prod.outlook.com ([fe80::398b:d0f7:22f:5d2b%3]) with mapi id 15.20.4755.028; Tue, 14 Dec 2021 10:22:10 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, danieller@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net 1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible Date: Tue, 14 Dec 2021 12:21:36 +0200 Message-Id: <20211214102137.580179-2-idosch@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211214102137.580179-1-idosch@nvidia.com> References: <20211214102137.580179-1-idosch@nvidia.com> X-ClientProxiedBy: MR2P264CA0015.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::27) To BYAPR12MB4757.namprd12.prod.outlook.com (2603:10b6:a03:97::32) MIME-Version: 1.0 Received: from localhost (2a0d:6fc2:5560:e600:ddf8:d1fa:667a:53e3) by MR2P264CA0015.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 14 Dec 2021 10:22:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fb90c3c-0e6f-4541-bd5a-08d9beeb96b7 X-MS-TrafficTypeDiagnostic: BYAPR12MB3079:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u+UWf/uOqHnkMBg8QNKNHE8MsKIqlyYzQUnPR0iiS85zeIjSSp1COl8BE1oNKY1vdt6ZKzQAwduj+Ue6edxwLiA6OpjCMI9HSg5r4QOdrDgV8aTV8qmGH0V4bFP/j1YYgcex8vN6uhFgf6qKjnnDF78GK5Jas8FqE2b+F/fTj4I7mP1/APiwt6BRJvMhqX+Si+fwQXwA9mVEJqMCTEyCc1hJAEhJtSQ+qySoSsi7vLcpjSIQbWxxnBaOVN+YM9qipcIhRTaK+f7NBErvfw5jr74upEfFNHdoZVGdkYnMqpjsM1upFr9gwhM94Qb4dZQj4XSulaBS5oFYvZIsqSvnvQ9dCQOJIaGggpzCAg00DGxY9tSJGUAw6cHzMchHxswQX74YyXGM+CeghHZIKjerFLqkAfENNfBaPusLPSGwS/AUFUVvNijDLWA6bLTzCLO8dKzxxsZXOdCtf9/HM+AEZtWa8P1RI7GhEkqzsMMsZQSSF5HatqPq/qpRxaDHlprjJwl+PpITP++37I3ZCTirfEGsknyqpcql5ZM+hOCtBczgBGtK+rFBMndq2111FQi1Kw8KBYNwqU3wfg6KQd+UdaTtAsZQFPIJ05Z1LRFhr6hpQvxnqSncVgwxeefgWaBEtMWsmekijuijYHC4N9NI/A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB4757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(66476007)(66946007)(508600001)(5660300002)(1076003)(107886003)(66574015)(316002)(8936002)(8676002)(86362001)(83380400001)(2906002)(36756003)(6666004)(4326008)(6486002)(38100700002)(6496006)(2616005)(6916009)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1rhM0y7LeO+XPwLFjn3eU8cLgTHxuemrPc4TTs0EXjlBOPvDALowX6m2NsCZ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7c75vvb2h9vsp0PdblaExZXjDx71rjHwIqiqpnmE3xFEfYlgOdgIAnsc0hNlMAYMsHmyjjfpMj41qoMqG3UVEMpNNXbYSRz5zxS+FsjFzel9cRSMZ1iAExmQmjCwXLsGdi3JnXgWF6sQuXSYSDM/Z1miJAiZZnC2Dc7oEA8RfiSmcPMJEwQty5Vjkfg8lDxdGFCtC9vFllqa7Pm7RoUbR3uaTJYzmU6f1aOdjdA9tB6QEJRDSroCBAt4+Tmz0+NPj7tAsrqfqm4SHyBGZR9MTIFjD/TEpwiB5Uq+Z81oUVgVVOq7m5sLcOK6Tm+dTfooS1TgadJFkMKv+Vd+wwsfQgE3Rlo/ay6twnHHz+3mr5QagfBzYgPon1IVgwACmzvmlYDsmpiLQndN+6J2PWYb6NgR9FOwhcGNwEZyWD1DjFKVf7Ms7hIfP8ajQsp7CgE460BPAKUNcBU6G+/kLPZ9gom3ZSwjIwcWjfh3U59hKnohK6n6eFYKBvQYTFcqeQhuPbn2+yw06VqrllzoiV+scZJpUcifnDp6QmwW5rdSKd1+j9v/a2gdO6Ku5S8A= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fb90c3c-0e6f-4541-bd5a-08d9beeb96b7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 10:22:10.7507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HREN/QV2hg5QDCm+9U0fqwjXidQFz0tNSiikg72WGf5yzvr/lzKR2Ql7aVooxRf3v16A2fMJl3bxtgLTZl3dKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3079 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Danielle Ratson Currently, when setting a router interface (RIF) MAC address while the MAC profile is not shared with other RIFs, the profile is edited so that the new MAC address is assigned to it. This does not take into account a situation in which the new MAC address already matches an existing MAC profile. In that situation, two MAC profiles will be occupied even though they hold MAC addresses from the same profile. In order to prevent that, add a check to ensure that editing a MAC profile takes place only when the new MAC address does not match an existing profile. Fixes: 605d25cd782a6 ("mlxsw: spectrum_router: Add RIF MAC profiles support") Reported-by: Maksym Yaremchuk Tested-by: Maksym Yaremchuk Signed-off-by: Danielle Ratson Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 2af0c6382609..764731eae2cd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -8491,7 +8491,8 @@ mlxsw_sp_rif_mac_profile_replace(struct mlxsw_sp *mlxsw_sp, u8 mac_profile; int err; - if (!mlxsw_sp_rif_mac_profile_is_shared(rif)) + if (!mlxsw_sp_rif_mac_profile_is_shared(rif) && + !mlxsw_sp_rif_mac_profile_find(mlxsw_sp, new_mac)) return mlxsw_sp_rif_mac_profile_edit(rif, new_mac); err = mlxsw_sp_rif_mac_profile_get(mlxsw_sp, new_mac,