From patchwork Mon Apr 18 06:42:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12816345 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 2240CC433F5 for ; Mon, 18 Apr 2022 06:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236882AbiDRGrr (ORCPT ); Mon, 18 Apr 2022 02:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236909AbiDRGri (ORCPT ); Mon, 18 Apr 2022 02:47:38 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2084.outbound.protection.outlook.com [40.107.100.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A82F7E for ; Sun, 17 Apr 2022 23:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LVNLlLE4ZuYTzW0h5+5fiJySC+8NYeP/OMx2OTTBm6RG302U45te7qwjLaQNwqFjF2nXPUoPhwg2iwugiDFTVQu90LBiT1FaSYLMHAEcshEWiedHC2jPqtz9ZgkjKiWz5EtIgjfkfaklC2+6+15VAfKzW/lNP/akGO/sjY0Juspcq8WCAXVfsYmhfIWENr2W2isQ6PeDNboqG5t4TqmtD+jua6mboXK6Er0RiRz06rWbg3tcVkbDSRpXAziGXxhf9JOOiGv+lg1JfYRIDMbYRMscVwrFV7MQaZoyGUHeh7f59w5VhswS1sLExky7CRAlhe1/JrvbGDd4VsuK6PqmHQ== 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=URwJtH/4Z5IJZnUGw9Q5gNo3D9G+f4qm5qCqGm6Hk9I=; b=dXliHGRxtWemZM0RYgvc1fkqrQzTU27UlR4GMnqvDpQkNKxaEOtAh90p4+59LZLmCNybMVy2X5Jzx/8mxW/p6cW2ooDFaRqbwqcnrJpMmwdV3wziuu3WZWxPZxKFaErAy7cOdz6IxB/qVOLiYsgqPSj53baRqnUFk2Zpspbux1sSj0AgdOn08K8Lp6CMfhcImixGNUC2PKn0WizpzvKilFGbIqZJYDRzQ+UN5T/wAvtvHfj4OWTZOt15j93TgtKCAziLW6Pj2ucGzhF6ch14yepq53lXyFaF4oSEmDHmROVla/L8roYEhMF2sDFx6DqWnSF6GyALnPF+OUzOFMNSLw== 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=URwJtH/4Z5IJZnUGw9Q5gNo3D9G+f4qm5qCqGm6Hk9I=; b=doBfISZnrw0IKAjKOfnCSz8Dp1GUWCzLLVTNzKsqGktD91MhyHpDYc5QcQCEqt84KP1fBadE1Agni9eUnsRWL7KiubmfPI2e2fsNivA4xRmFBCJhtKTPiG+E3rw3qF3o7zWyOQ1ARWeGMd3gIf0OxnAeUW3XXSR+jm1bPCGW12fvxaJAmI/pk74N2ZbhZzd9ZD5wA1ubu1kG88tZNx0NC06D1SeOLiRpVjAkprOLZqF98YXEF5BWb2hTi9PKHa0hLL8waRyEIen06bT/uQx6qHhC4FLlfbz8HORN2lvYa0KY378RbCT5TcRqQduniqJARtZx0jyGuH/4IDw+7cweDA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MN2PR12MB3664.namprd12.prod.outlook.com (2603:10b6:208:159::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Mon, 18 Apr 2022 06:44:51 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%6]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 06:44:51 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, vadimp@nvidia.com, petrm@nvidia.com, andrew@lunn.ch, dsahern@gmail.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 15/17] mlxsw: core: Extend driver ops by remove selected ports op Date: Mon, 18 Apr 2022 09:42:39 +0300 Message-Id: <20220418064241.2925668-16-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220418064241.2925668-1-idosch@nvidia.com> References: <20220418064241.2925668-1-idosch@nvidia.com> X-ClientProxiedBy: LO4P123CA0461.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::16) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb93ead8-84f6-4e4c-49c3-08da2106f09f X-MS-TrafficTypeDiagnostic: MN2PR12MB3664:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pGUUSMit+Vgxa8kVXs4Vw9tetHs9UgnnCG2ll6nnmrAJyVVcjvKsZblFqmuBP3fLsXneaU/pff3xqZXMhm77eO69bc3OO9LCc51imXJ9+VL7KdeWJWj7p1soS/5wrWW4DSsRcexlPriHAltAI+FrCABF1ELi709Mc2/xi4VWf60QQA/f/t56vsh5bavOkWsHKUDZBryJ9T2w0cioV1h9T6QyTYPE1sgy4syj2FkEzGPZsFIm0J6EBjcg1gTgPM8s61cGl2RGxAXRUJqkYWwVOvFJ6rpgsOVpILQ3bg7vmtQs1ZITkZC8PMD63JKtHSpBk7joEHearj+Iftcwt4oHXtwxGHQxZyax6BMrtfMcvVhx6a4fofzHisau9DR5WW2MzF/HhMtzzZEv8VDiMQwntRYmIbTbwC+fVb2Im0NlPvkrb79xnC6RytD400FQVTteMbATV+rG+MABJsvRadvV0T1VbP++nYWXFDK6gVIIQRmYNp2u5kRrW8NY3Wpj/0z1zmIlQCnA+XP7rRzxQp6ucZ3zjG2UpmNJ19VXZNWdX1PPSrjaMwS8DjXO9g4aOpN1xENH8Q7iZR/tKSE68DEgMQuE9BGN65NbPCQOFRlzUJQPFX87TX1DMNIfnEEygfTcd69RQ5eFGziZuNiVQmYrEA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(107886003)(66556008)(316002)(4326008)(8676002)(508600001)(8936002)(6486002)(66476007)(5660300002)(6512007)(186003)(66946007)(38100700002)(86362001)(26005)(83380400001)(36756003)(2616005)(6666004)(2906002)(6916009)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AFf9M7yafGe+Np9LaoUDTVmTJH8/Tr7ab+J/wbxre97wk5Qg7InCk0A8b9QZS2gljqPv1WmtXnbuu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PIRDaZ/SnNLjRuwyOo/fb3sr/V5A65XEZ0/QZqW1FpCzllv+oxdB+1jnrYFC7w9hVy3bC5WM8hBanUhw5YrdJW8Seum6cx/tX6PXXzy4YOn1gAlXaulacTyGVWQX8yiHf2phfWuo1p9fyoQvu9rCHcS/2LOvmZcviZweXxI6pO8HT4OK0FA/dvIc2matGDCwKjAorAYeM8rK5fcLct5niWS9Eegu/NJ55Wz7uHmEKJ7cVj70HTZQmacO5DD7UPGzKmsMT22vlVU+N0xZnCY1Acv3ir7y7OFW6ou/PTl2Nzwla4QOfMAQGSYErSBBpoJqAXQJpGi6Ab1Nk9uo8ftomXuLAT3XRw38U4509rK1nnEvAskkZLAyaapOGggCGpntY0dhS2oWSYrbWtL2ZO2/zlaLopAmhmr1Ys3PW0/ip69UwGVoG1YRoOssaP1sY1BSjtcJedtHNc8XKzePJrFSeFutVC1CV9yUVmevh9ENxuARfmQc7YBpsc6lKbTL78WPl8rpczrth8MCc7mM23QjahDIxg6CQoTa2JjFvdzI9k6M7W1ZOAwG3M2lE5Pd+LTGdvH1wTM07awWv0Pud5ILbK0WHVQw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb93ead8-84f6-4e4c-49c3-08da2106f09f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 06:44:51.7931 (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: 4fedd8rYwMKlyswlEVEdQ25q48L3JcWWGL1YW1+55W3ree7wTus98isAayvOTKkNmD4/TU8R1eWsYafSBpn7AQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3664 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko In case of line card implementation, the core has to have a way to remove relevant ports manually. Extend the Spectrum driver ops by an op that implements port removal of selected ports upon request. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.c | 9 +++++++++ drivers/net/ethernet/mellanox/mlxsw/core.h | 8 ++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index 5e1855f752d0..9b5c2c60b9aa 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -3143,6 +3143,15 @@ bool mlxsw_core_port_is_xm(const struct mlxsw_core *mlxsw_core, u16 local_port) } EXPORT_SYMBOL(mlxsw_core_port_is_xm); +void mlxsw_core_ports_remove_selected(struct mlxsw_core *mlxsw_core, + bool (*selector)(void *priv, u16 local_port), + void *priv) +{ + if (WARN_ON_ONCE(!mlxsw_core->driver->ports_remove_selected)) + return; + mlxsw_core->driver->ports_remove_selected(mlxsw_core, selector, priv); +} + struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core) { return mlxsw_core->env; diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index 7d6f8f3bcd93..865252e97e14 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -258,6 +258,10 @@ struct devlink_port * mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core, u16 local_port); bool mlxsw_core_port_is_xm(const struct mlxsw_core *mlxsw_core, u16 local_port); +void mlxsw_core_ports_remove_selected(struct mlxsw_core *mlxsw_core, + bool (*selector)(void *priv, + u16 local_port), + void *priv); struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core); int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay); @@ -331,6 +335,10 @@ struct mlxsw_driver { unsigned int count, struct netlink_ext_ack *extack); int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u16 local_port, struct netlink_ext_ack *extack); + void (*ports_remove_selected)(struct mlxsw_core *mlxsw_core, + bool (*selector)(void *priv, + u16 local_port), + void *priv); int (*sb_pool_get)(struct mlxsw_core *mlxsw_core, unsigned int sb_index, u16 pool_index, struct devlink_sb_pool_info *pool_info); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index b4e064bd77bc..c3b9e244e888 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1999,6 +1999,20 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp) mlxsw_sp->ports = NULL; } +static void +mlxsw_sp_ports_remove_selected(struct mlxsw_core *mlxsw_core, + bool (*selector)(void *priv, u16 local_port), + void *priv) +{ + struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); + unsigned int max_ports = mlxsw_core_max_ports(mlxsw_core); + int i; + + for (i = 1; i < max_ports; i++) + if (mlxsw_sp_port_created(mlxsw_sp, i) && selector(priv, i)) + mlxsw_sp_port_remove(mlxsw_sp, i); +} + static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp) { unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); @@ -3785,6 +3799,7 @@ static struct mlxsw_driver mlxsw_sp2_driver = { .fini = mlxsw_sp_fini, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, + .ports_remove_selected = mlxsw_sp_ports_remove_selected, .sb_pool_get = mlxsw_sp_sb_pool_get, .sb_pool_set = mlxsw_sp_sb_pool_set, .sb_port_pool_get = mlxsw_sp_sb_port_pool_get, @@ -3822,6 +3837,7 @@ static struct mlxsw_driver mlxsw_sp3_driver = { .fini = mlxsw_sp_fini, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, + .ports_remove_selected = mlxsw_sp_ports_remove_selected, .sb_pool_get = mlxsw_sp_sb_pool_get, .sb_pool_set = mlxsw_sp_sb_pool_set, .sb_port_pool_get = mlxsw_sp_sb_port_pool_get, @@ -3857,6 +3873,7 @@ static struct mlxsw_driver mlxsw_sp4_driver = { .fini = mlxsw_sp_fini, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, + .ports_remove_selected = mlxsw_sp_ports_remove_selected, .sb_pool_get = mlxsw_sp_sb_pool_get, .sb_pool_set = mlxsw_sp_sb_pool_set, .sb_port_pool_get = mlxsw_sp_sb_port_pool_get,