From patchwork Thu Jan 27 09:02:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726425 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 B7AABC433EF for ; Thu, 27 Jan 2022 09:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234582AbiA0JDI (ORCPT ); Thu, 27 Jan 2022 04:03:08 -0500 Received: from mail-bn7nam10on2081.outbound.protection.outlook.com ([40.107.92.81]:31969 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238134AbiA0JDI (ORCPT ); Thu, 27 Jan 2022 04:03:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ennv39QHO4FvPazQICx+n9SDd1Pt3+yT5VM7ns6UF9MR/Iv1BKIbr8KblMSgE9ZYsmOExcYn2RXhD813lsewI66aE8HlmgZvNEe8eCLR/Aqt2PnM7aHoCFonvGCHx7M05A7OLvf4VHcPRrNlsJmDKiWvvGCeZSOaAWkEdvZ60meA5LtTpGaZ+58+j+uylQu3c+9fvJmjuhQTV4n0KeXOtRFny5GYo2/Oexc2uH6NTmwDerDyJMho/N8EP5Wq+Ar5E5CF41ekOYY/mw99/N5KY3wR/0U63xsREgunbEZpRiHff6yNWXz0rt5hOnxGW5cS+7UPxAGOr7da7pZ9MxN9ew== 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=cTvPm9PxGRPlHpbNl8Spe2YXd7SWIH8NWrZtBfS79QI=; b=liyW5NddS4GXUw+Nejk2Pj5A3TIliHnewYC3PuO26W9RC95RefYMRTloy5OrAuW3ygGvE1cGGBBNLYGh94uZVglABwQZz3Eor/MHL9HvXC3I+6+nmXESyiKoB5x87d+drVMJgrEMnhVN5RxzKiue0Bev0wgSesBNnwfNiU4kvIhBgueFG5qlYMWugl0P5FbHn1ZcunEq0YBOWHCQAlTIxJRHGbRXnXx8g4dB7zZy+RXB3quAN4BgQWlaSpcTuvfy0bKrELREmoeaHSvJKKO3MnQcuxeN7qUK2n3klzJupeSvr2WkD6Ev9veMdJsReNSde95j9UwEQY3/Qgoh32kOkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=cTvPm9PxGRPlHpbNl8Spe2YXd7SWIH8NWrZtBfS79QI=; b=nXhYai1rRgGpDV6mgF86dvmvvmQr9tXz2XFZUCd2OyogUyNjZrRydXvlPQV4jYSuZd97BSKoafHrKgWNx+94NFjPwbWmymLAp/2tXwcjzoz1yJ+i49ucayBzoosVUFnPY+dJKz8mwtnmNTXhp6aPswSJaivFWCao8aJab6zDFXogAPX0KorDPT4mdoeM7vzzDUrZVnmeh27mfhXbOI5935vhMAhBL0+sEkVMChT51bB91w5lDyHAtQx2ADmwflTHMeJjXeXLVshQrjigHvrvBYlkYUVgjTHnUEU4UsppBu6gWkdZEhV66XtcSKC03Hg33bc+urUmtwyc32wPGcpxZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:06 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:06 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 1/7] mlxsw: spectrum: Set basic trap groups from an array Date: Thu, 27 Jan 2022 11:02:20 +0200 Message-Id: <20220127090226.283442-2-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0801CA0073.eurprd08.prod.outlook.com (2603:10a6:800:7d::17) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4433c24-7b49-4ab1-061d-08d9e173d50c X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YOe8+gGm7Rz8nNqNdioAXxmm2Tw8j+P3JmEA4M9lSCtTguXEb5PYtpHgLs7LWKEKW5pk08C77HEMZWONeOhadlLvjiQkHlF+Yl6MR9y8icPsufpVBTRsxlfLvq1tlaBYEs0n7nINYzPMC3dRapMrmFuIOTPhVjPS92u6zKvFv9GU/rNwIydLaTLNUbBqkOaBrfkKEjIsDMBsmRnKXTgPu7SMQtQmjx0O+VtbidiHyzACA2W2+d5EYiy6f8gQrx1iLBKFZLTOE9RGDkkb34n5PBvrjIsXTqeIWgGqrgO85/1MLUMgdyq1UbKk64poJ2J+2ov5GZ+s46Z6Y1ils+P9HNPjny5j6nOstpiJxYwNUcYeYqKn44LPxuecLcR/Z9HhPVn95WYyG5ETPbkAPYxysZA31uuCpVp772ficqhSiWxG6fobqPUoBMGOilWX4fe8dW01hkaIs7FciHVTXedN6V7j9UY1eESXo4/KMGMImuKm0kuEWU3tYBowaFelnfOPsWXhakodg/R3qtALF0RMHX0uguRkxcmgc/oOoKQm3VVxUROLhnBBwSOytz+xVn17Rpl3iX97EfGl6fLirf9j0qp1jZcq9XoyGjf2f8AwQI79T8PcP6o+kER1p8GekyPtD9zJXFNyxaFldQDR1uBI9g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(6666004)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kDeYP/tqrIAGW0yeJBW3kJdUm4CVyiLOaR6Qtk/m6/1JmIUmlxgfREOc3lIcM+Y9aNC2VOwB6Yb3NCYUWMQVpgVH+n8/rdAlX9seBNLv1GuxC47rea3opEkV2n7zrDdadM3jVl5LBGqIzv5lW761aipr52NVsgVT+aqP9i2DdgxNy1o2XuI0WMaduQJz53eERGUdamSI5U0oU2fMxZHbwHtKf30HSnwS6VyNgj2CgVkn6OYz4vbd+XxpbJim52nda06WNaJupTzw58ctq6wW+ka1YLSVAcQAVYLUxUhP3c1/BJ6mGb7pbotptEGCQxO9DLuA6VGLWRbCh7gSPyzs71WBQsUqXqx7C7qAyhJ8YOOw3oqSAlutWgLF0Shi5YSQFSfcunrZEK2FjPuhD6ZCFKj5dskvsGor+b8wNr7KLQc4qKPshggl8U5ux3qIf21PcqnYRvgmKkU04K5961hb0qadoebZCCH85uOV2ALoASE8G6H9MvjKJet4whLTbY8c3WoWaRETiMVn2MasXCl0ejSl4ELMarhlh00dm73CcsfgDbDFe3bKa5PNjuYDlGzBOD9Pl4kKhJOXwF7lXy0ka0EjzG4i2IEdHG6Zswjx38XbfK0wQFts3sq2yYzs8yzt8CfbFVtey/kvAF6MQnB/S2PabOZc8g4Hps9kVE93RRwhEKc6M1rDOoBcWMk027U1xv1ctq6nKyp7nxJnxc+yognRBj8S3dmjLKF/QmIrGjTJ+Q5y0LMBhxrjQFEf3TIYJERzaF5ZEvXLFql7bYyz1Op0erFE5xhOAuSHl5foSGx+ZhkPZVT4XaR6J39B1UHGqx6nAciCndL+dXehPc+UPJysItERNQ2sHBKNH0DciHaezGnyMP44C2QAqMpGNzRZOiv7iXF6tphtJ9LK0LcZwbCv8m6Tve32VpCzvY4trVHcrb1pGBIjAKC1Q6gxnuaBVL+8sUPX963eJW5PsAQ35yBndQIXWbcA69JLWvqovHJPvjj8bN8rKQcI0c9d8bnObHjzjvZFypoiddmUEzlC5Qevw0g1nDcQmIAH8pCXfPCuOn6CfRd6p5rSjbwVzz2phABHzLMMyKeOliucqvx2iQw+v5UIhCb36XxYS/B9/A+IRuOBNJU4js0fRFMuXkBI7VTYbhxb/snou0NnrQwi0GRKT2goLN8ItOQPcrju+pRNXx3zS5wy89rMJeeCSQak2VBFngt/kv/2usSXAjWr4SJpcOYDR+ofYlvqDxdJcyBUF+elHlfMDGiVXRQAOc+sKRuUT0up4OYMlPYx+4uwt1roVmV1DzNqBjw0CYzN1imxFFBeWyBVsLkR5WnJJ7bWwJ7vwg4WvCYqM8LQ9TUF2HWWtK9/jxPc2XwxDscEcAvx5gHxmg4ko2TgRcj3XBEj0mQrRczlLXMNuof2Ya9Fb5zUfxCCQy5OOKNmCy8FPFh2IqMlpkp42DoyxacojZ5bdlWx1pM7wyLU1DiDnGWTx8txKbe8GLx0Af8T72mE+Gs4LNlt6EvwhHmiBV6GEnf0fWBnGTNhNz1cKdJccSt/xcN9KKbD6rASdozBf9thjn24OcPmnI7jr/9yonAkv1XVTDo8j4/90CIVM03i1DOm+aDGpS6kZuLECuL8OIi8cVE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4433c24-7b49-4ab1-061d-08d9e173d50c X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:06.4584 (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: mTMd6wUaaUNjYxb5KdrP2KTqFMUnQmz8ZpM+MrXDvqGCN7PCqpMjsDE1gGVYCzGdCOt7pnZE8q9QmIV5GnPH1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Instead of calling the same code four times, do it in a loop over array which contains trap grups to be set. Signed-off-by: Jiri Pirko Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 47 +++++++------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index aa411dec62f0..4c6497753912 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2528,40 +2528,29 @@ static void mlxsw_sp_lag_fini(struct mlxsw_sp *mlxsw_sp) kfree(mlxsw_sp->lags); } +static const u8 mlxsw_sp_basic_trap_groups[] = { + MLXSW_REG_HTGT_TRAP_GROUP_EMAD, + MLXSW_REG_HTGT_TRAP_GROUP_MFDE, + MLXSW_REG_HTGT_TRAP_GROUP_MTWE, + MLXSW_REG_HTGT_TRAP_GROUP_PMPE, +}; + static int mlxsw_sp_basic_trap_groups_set(struct mlxsw_core *mlxsw_core) { char htgt_pl[MLXSW_REG_HTGT_LEN]; int err; + int i; - mlxsw_reg_htgt_pack(htgt_pl, MLXSW_REG_HTGT_TRAP_GROUP_EMAD, - MLXSW_REG_HTGT_INVALID_POLICER, - MLXSW_REG_HTGT_DEFAULT_PRIORITY, - MLXSW_REG_HTGT_DEFAULT_TC); - err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); - if (err) - return err; - - mlxsw_reg_htgt_pack(htgt_pl, MLXSW_REG_HTGT_TRAP_GROUP_MFDE, - MLXSW_REG_HTGT_INVALID_POLICER, - MLXSW_REG_HTGT_DEFAULT_PRIORITY, - MLXSW_REG_HTGT_DEFAULT_TC); - err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); - if (err) - return err; - - mlxsw_reg_htgt_pack(htgt_pl, MLXSW_REG_HTGT_TRAP_GROUP_MTWE, - MLXSW_REG_HTGT_INVALID_POLICER, - MLXSW_REG_HTGT_DEFAULT_PRIORITY, - MLXSW_REG_HTGT_DEFAULT_TC); - err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); - if (err) - return err; - - mlxsw_reg_htgt_pack(htgt_pl, MLXSW_REG_HTGT_TRAP_GROUP_PMPE, - MLXSW_REG_HTGT_INVALID_POLICER, - MLXSW_REG_HTGT_DEFAULT_PRIORITY, - MLXSW_REG_HTGT_DEFAULT_TC); - return mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); + for (i = 0; i < ARRAY_SIZE(mlxsw_sp_basic_trap_groups); i++) { + mlxsw_reg_htgt_pack(htgt_pl, mlxsw_sp_basic_trap_groups[i], + MLXSW_REG_HTGT_INVALID_POLICER, + MLXSW_REG_HTGT_DEFAULT_PRIORITY, + MLXSW_REG_HTGT_DEFAULT_TC); + err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); + if (err) + return err; + } + return 0; } static const struct mlxsw_sp_ptp_ops mlxsw_sp1_ptp_ops = { From patchwork Thu Jan 27 09:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726426 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 57A0FC433F5 for ; Thu, 27 Jan 2022 09:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238168AbiA0JDY (ORCPT ); Thu, 27 Jan 2022 04:03:24 -0500 Received: from mail-bn7nam10on2047.outbound.protection.outlook.com ([40.107.92.47]:31201 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238178AbiA0JDR (ORCPT ); Thu, 27 Jan 2022 04:03:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IxmwyIYHWAekciDu154vqV9Ckrf3iwyu+Wipqk3jQGq36gQH6Rs9yYpMKQLZbVI5CFUlYacg2eGg6pLSLDBtgZEcDUZixtHr5gf3c+V5xC+NhJrh1h8l2svylsA5+8eC/1H8pqS8NF9ywWZ74v/5JWi1jkOduJag/UX57oFrS6l6N/oQEtv22jJxQ+bKlyfAD4YmMvtJcj8FzXnLTKjQ0sOo1A5fwayZimwDEFsEzolw8jpVuM6EsG6NKBoo9bkrwuCSQftzwsYK4E2jYXPXTh+8zJRbkblA8AfCM1we1X7ykNgR7c399zlXPipTfcvLvBvD+LrcVRWsd5xLEhKvbg== 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=Owhrqpujj+IDO+TYtvw4rn796TVnWYyHPWru+u4aAMw=; b=kcBVVFXNjLJx4yZotu9fUjzu5NRU7QWSyJR6tNUQfTrrxdwTdNuVNBqk+eLg4+CTYA3eQ5wSGON3bVyV//Fkc53XF5JrSFiDBfaQLhmUcLqmY1Wm2+RsXehXabaVWNKXXJ1oAz4pQprCUGJ7Qziz7nks3bBQrlPlCGHcDPe/pWVm8ekHrkEYyrd9uKX8U6htxDdYMWArtvNhvYN66PW1jAmnhiFV6oRnyVkz49RU4xMOcnQfTfzAZcfkTf9oUY8elYybxna/o15H0T9SMWVkp+LmuCj1U2kxZg73NI9+UATQ5zTRNJ+HzUkc5egyQWoTb5oeAy/SaKmZ8NWsz9ioFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=Owhrqpujj+IDO+TYtvw4rn796TVnWYyHPWru+u4aAMw=; b=RuVCucEvbi4BLgi8jIzJhzIySXaZRhPUa9HeDXuL9WKzopRt0AgqxBIXj15JS+3GIohnK7oVBp7H4jAY+KUpFIFLikHhTpmNPYHh5BVCSpTqfyllciwkyl+gWgUXgHH77QSw0VOn7zsI7m3DbjVvHsUOkaxLKz726OP+OwBC93qGhv32q2auyWocgalDnDY6jlCIN94nNh4YI/uglsQINH63twZpPhZeNzCdu4APUqvWwcw9JSq/ovyZppoiEI0B6cFBWv/CIqGKgeVeGs7ws1hrzRnu6JcOczTUPMn5EcsHuY/QhY3MQo7MLmxz1Ij1yikCMlHPTbtIqtzYE81CCQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:13 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:13 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 2/7] mlxsw: core: Move basic_trap_groups_set() call out of EMAD init code Date: Thu, 27 Jan 2022 11:02:21 +0200 Message-Id: <20220127090226.283442-3-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR03CA0048.eurprd03.prod.outlook.com (2603:10a6:803:50::19) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d211f9b-562d-4dc1-b0f3-08d9e173d8f7 X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:85; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0OirGOmj+QXZj00A41N6xHO/5LJbb41C4DMJkCsXobNpGo4CUQe22ikpbMVaPLsxwygcSMWScdFWSuQm4vRh6+OCIiP8wQ1Yqr8LUxUJpuL88K74HRwF7Pp8+zW+01F6zuTnOX7l/SEMI1MwVHLVOTXO8JcW9h51h7Z6/F8u84xhJ36JcKHvdaANTcQNucrmjOkdWUW8ews/K6OGWb0N2D26NI1TO9q88+k+dAWEPIygOvpDWtIU2TeiX+fw59EzE9k+Jrq32SGgPp7aBrVj+MnGTgTaooSn5O8tR0FV5f7CczsJtv0JnoC5D7RZzWRADYnuTmf/uUB1+D4p94lVPW8C5nSkCoFXhz5dvh65aueIO+yQBFHxbUGJfN1IMIp5mqXIeftO2hhrkzeYGpa4fA5fCtHM+VkHt6YYZMhzQBIMzeMSbYAX1W1YJJ/xSshEajvu+ZUc5LLn1g/ArQJd0wmO7xZVyHg2eNU0bB/843y6r++X8cdoJ1aQaoSBzmr7XlkVjjsh3EDHgtjDmdAXHo3ki+AwyJN5v9u7RkGhS+GYQYOddoyVQkHd4Ew8q6rbuP23ZdMDiMRdbsCwgxXXlX06j6oGzC6eSftMC6PJuBTsKBeTSJxyQaJ8UBELISPTsCepDXRL7rBQet1/LbYP/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(6666004)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XMi02Ddj5nCJOXkCJ8wfmOXB9IDek9qBASJYiJTJsTGIS3lcBK2YKkiQlVcu4mw2SAUcAUZONLKzJe4GS+JZW3DDlyqRmpCFsU98ipkKLeaSQ7rhnxavqUtidhv0dFCT9fXC8V+aAQLDs5KfRwGf2SjlCjCPV53B+asMUzcmmKfRqoO54H3chBkHfQopBGZGH3xS5nr6bHEnck1l56XBzMvNfmfjDzKilPTDtHQWTwyH9FR9g5ll0EVFCXobV1lODvqOwePwLSBfwI+NMHG0uG3tjTYeP3FHLBfbvloOzVpMPT5sHPjP9zd4RBIw5cdKeJA0BKLzeXU1RZLGibc1fFUjlcyVc8mE6LDoF2aVxew2VNQY/Ba2MdG4RLAQs4LGh4oKifaVQKTgPqN0kgNM3p+3gckEONLi93SHEo7ZA+vSgqcco3Cko2HIWrx/wlvroaUMAhFFJJ/BnET+UnkCRN9OAMYDiDjXc4lrkHmRugTbiH8M4Qqxkalg6GH8VlmFu8+DePVOIXmbJhQnTlfVOENQhDTemCMq6h6VJ5bQsC4nEZPEc6+Sfrg0naiDtFKDaFdl/mOvgESdcA/qjAHw6bWgAZP+g4ImSVrAqZAkaHlFBQ6nenKtPR/Ll3uSeFPvm/fmvF82Wbko+RN5JjyAt3wjo+bV8xuxFavqVMN7TO39bLL9HsA/6Sjst0v8tyExoNrItTks0YwbkWUjlhetnvfnQACoGKsxQIW/+PmQj1THjCJyjUbiHmdF1nDKHzNIxktt1h3Akb8N+hyoyGj1Ce+1nDt1/8Y1oWk3oWerYxJRTkOWiguJSAx8sOeWb6db/j61axmA0RHGjc2VsLpGTd1fOXHHhZPpi8kbUfNZZW4fmHF/AW4/uF6bNCM+l7xLzO0akuJ3OhA1Eh7qDiYO4elWUm9POf3LP9lKcoyGCoQHnr/0cApFaxK3MkGCvXrVwZkT12O+EpywCJ8bvOFzBJnvn9DEmP8LkbFeZfGlbCvabERSr90Sqn/Ya3IJhhHKNdasm14ky3OojD7MyY5e40R8h8S9UcltMRPJDASIZor+ZZz1gtdvXKl17NNQuJwbVUf8yijULP6SF3t0RDeiO0wSzT85NiaNjdPO/5YqrcPIFe3ejocFWlv+8NJtZ/A7dGPVkMnPa/v/7ak4OiZKulRo7O8/RC6GLxAA+emfOBEq7wDzGQ5t0QCssnj2hK7AqkOs8t6IL0/8ILAbz33jDoG49aUkd18FvXZqMMLYn9i357qvVELofEiDFlxP3Rwt1ZBcnfzhoIwhffvRyxNWj4etsY9XbYrBv+yLsuOBusdvWYRaS49W4M++unTKVn8po67r1kQjeE9kFFyx3EaRQfEy6BieZ+FQhW+qagAT/SDi3C+11MtAh4FffZb5hQx2xHVn+1JAj7aR5Ln8mnqM6F22/B0Q4K5jS+1YvBT5lUWdI3Nghp2QEcFzHWOZyECj9FshSgQ0s+KLwm7g0MaYV1Gq0SQD6Z/9JsBJFpSVF25+SCbTCm0TbdiRsF44Sx7dfBIEecuGaqbQzjtQGwY/goUBsV41UthcfoXn6SrRsoyMcH9IIwKuqei2oFjNYtEGhQwy4mLTwo6KFOkNUpIQ8Ou1M1xYPU0r+5U/LB4wJ3A= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d211f9b-562d-4dc1-b0f3-08d9e173d8f7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:12.9579 (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: 2jR61SQZqykPO4RrzwG9CkNMXuKDJmsyNHrPJVhyu9Cd5RwUVXB8OEcK8B8OnOKFZgxx/+lmIuxYPaCeGmQEMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko The call inits the EMAD group, but other groups as well. Therefore, move it out of EMAD init code and call it before. Signed-off-by: Jiri Pirko Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index 866b9357939b..c9fb7425866c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -212,6 +212,11 @@ struct mlxsw_event_listener_item { void *priv; }; +static int mlxsw_core_trap_groups_set(struct mlxsw_core *mlxsw_core) +{ + return mlxsw_core->driver->basic_trap_groups_set(mlxsw_core); +} + /****************** * EMAD processing ******************/ @@ -777,16 +782,10 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core) if (err) goto err_trap_register; - err = mlxsw_core->driver->basic_trap_groups_set(mlxsw_core); - if (err) - goto err_emad_trap_set; mlxsw_core->emad.use_emad = true; return 0; -err_emad_trap_set: - mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener, - mlxsw_core); err_trap_register: destroy_workqueue(mlxsw_core->emad_wq); return err; @@ -2122,6 +2121,10 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, } } + err = mlxsw_core_trap_groups_set(mlxsw_core); + if (err) + goto err_trap_groups_set; + err = mlxsw_emad_init(mlxsw_core); if (err) goto err_emad_init; @@ -2181,6 +2184,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, err_register_params: mlxsw_emad_fini(mlxsw_core); err_emad_init: +err_trap_groups_set: kfree(mlxsw_core->lag.mapping); err_alloc_lag_mapping: mlxsw_ports_fini(mlxsw_core, reload); From patchwork Thu Jan 27 09:02:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726427 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 C1133C433EF for ; Thu, 27 Jan 2022 09:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238162AbiA0JDZ (ORCPT ); Thu, 27 Jan 2022 04:03:25 -0500 Received: from mail-bn7nam10on2047.outbound.protection.outlook.com ([40.107.92.47]:31201 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234583AbiA0JDX (ORCPT ); Thu, 27 Jan 2022 04:03:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MR19RscsQX1uD+zktQzP1G17q24IGkDwkS6KYhTMLHc2qzUqtrtAy1j2DnRG2zd8uq64um4u7ARdSG6svKyw+4es45Z7D7PNC1e08fHhI1OVEXpYgfqkiAXd3yDgT/MUHkC/6l3rMOpvmxPPGPq/sUpkEjpx/G2vdowBvbOt2SxrmkqBBRNhSCZ+HgsdV+Znnz2a1bhpq4V+cXhlrX3VFCB2TV0fXFlugRdMQY7MUWU969EJ6JpxjjL7j+YETTROwWGAF3LTSrRgXEAVa+ZqJKfprTuxnrT9p1Ps7ucrL82oGgLz3uSgIFIMhZSQkV5GmzCoTPSHxa6Mk2T9lO96/A== 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=oaz6YiHBDK/S8qYg7YimCt1ZGu8MoiWmIGb4flpr08Y=; b=AfhI92BZNC9c7BBYQhCW27bDN6CYIkxtbiVLT5eUm01A6MCg1vLeYMnJvG8mLARm9qag9EogIbeZL6bs6ZZTdgNpMXvGU6i6LLReDgqdaqSnj9aCeE1baedggHT9Kga6dQrU01HfDQPkiOXnkmzzgRDvYebDoYup9xQIYqXDJ5hG0IqtbbgmbazbeSGuoWozgeoET5QGXE9iWU9jLetZKxcRxm3zQVpsO3IgQECATnMGlezJfa6RyztIyaZAC0+kBsZ9HrVNSUBLhrtp6ZMPkPa1oC6mWhQhy/kWyJVnz1+NVYThv4FVimQxGN4hSEsInRr9NrodC+KzQWIvrTyW7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=oaz6YiHBDK/S8qYg7YimCt1ZGu8MoiWmIGb4flpr08Y=; b=HRCpnUyxMIzy2sTCmtJIuGnTOqA4Pdb1XjO10Gb2ZsjjG4CcQ9JuZH8DcMUnf8HgRGXWQ0tOmF8LbnmO+7cnLZdYBt5HEiNlUHYZMAoPsldyefJQYTTt13bWXneprqPhmZ8Iim+BzRqhg+1h/3oBcICuthFNLlKiSvLZvSPpBWL00tN5gLlQhMPlmOEJg7z7K6+n/VKsjpMldNyab28Hee/rTQLOoEvIEf59hgmQ9lvE2Z9GEtJUnTCXP6rogSrucE3A2ZXm67OhbaIUS3sLhmiw+OhZ37+psQzufERuewEzPTfbQfRJy64DHowupawA6lfSAcG1QcFJrqVc5aTPQA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:17 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:17 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 3/7] mlxsw: core: Move basic trap group initialization from spectrum.c Date: Thu, 27 Jan 2022 11:02:22 +0200 Message-Id: <20220127090226.283442-4-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0901CA0102.eurprd09.prod.outlook.com (2603:10a6:800:7e::28) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 050b5b12-55dd-43b7-e2c0-08d9e173dbe1 X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ar/XbjbVCKTty30+lOYqDAIutXWhxygsSFzic4UImd0eT6us8UEPhXeSJNInm3VMWgBRo/xI9/d0+PurqCfbJjuQ1GWgrh+6/5x8JxnsSYKWi0Dkjix9XKOcdqERVEDG6fwSCqBPXov8BIO1WGCB8ke7BF7ijvR1NYg/HZysRsEViySoJdVNxByhBOVg0/Zo8Ky0OaXk5QD0lb4nkGkXsysuJykIBvSfsRFikVD25slb4RUiIxLWYEbowcRz+Ryt3sh5/g6oUHPlQMY+nmdcFnQa3CwXyeMJmgSCgxlFGCgzMWVh3jMWOSMugXiA/yr+R9vGbg6tHVy2qIjQGAuqYJkUEGJVfGYbzwUEw0cmlNoV3tEaRXaNeVY3H/MlVYvhLPTVrUzNGyjHJJJBuAmWePOmIzYpbVhrt5QrO2SgPySksJFi7+hVm7EQikVa5HZKEJhQXvWYOh6FGBUYxsEu6JBeCpjHs9qA/pS0TDpa68//rVWw3A3RdPZ3+6x3oK41y8QzfUTVum2nEb5dANX36+jKHpGQH9NNky0a1OOkO9zPvVclKc6ypd+ziQvOwSWnlIDoZ0FjjGNnkHRiM2IofcANKErwl+gSmHeMCY9UVQrFpQXxecvVGn+nbcgWTz/3VpBaDZ4dvisC9X60/+QyWQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(6666004)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S7ueKOM6hDJJ33Ls1DFOSD+SsVe2l06Zwi9GuYEjUV+dNrcyQyrOFYGbIj1eF+UJHAEp/Drp0PCGmrVVwFgoQHDm32g55lltRDME7H5jCZjZWSuHqN2HAjIks5fj5YkoPXVOMu0fRfcGvoA65KOMbI7B4JjFoKsV4gM2BNWAYGpfj8hmgHNNix/wJZMinVgJOM5pH8ZiZL2tDHPQeRBvSjoU0+tJnxSwokwN8JDSXP5GVChgK4jp5epvX1hd26y4SwpVp0Ogr4XcKE30+4uDTi8p82lVpVAEiOJGfoBegp/Te2yO6FzflOE1m6fzy6EWBohF4upd8t2fokxwW6YDzHjr0HRajeiwNfMFtgRFFJo9cfws7A0AADo8aip74qNaK+mnmatE1aS10IuNs5mGJ25InlcN51QsIPGMQeVHlS9RyPV+hqLmgMi4RkkjTkJINKMdjcFZYFyxCrydle13jQq0bjg4V1mOOBCgMprxEbcwh/IH8H9sJkNMlCl+i7qlYTPNH8N2O3uDnhKUvD0E9/wFA34/ZdJaPW9CEQfPxQhF0ok+imjptucXDhxHYyBr9OqRY0/Sf9McTfgmAP2P5uvc+l5mPyCMONmCTDplVyb2ns+PY7UqZ/u0LFT6w4kKNas0whMbqNv4KijQICC46f2BpTnqDl1Gf6LSGaO/HsT60+P0GUaAHCWgFZlGbrzwNCZTrNvc9lZ1cyDirPlZZ4iEVi2sXpWGC7zHR68A1Sw/FBdjSNfXfF4570T4SlLqYvn7bjL/iEIsA8P3rcBIqAg0AuumYfJBLHESFQIjaRLxBQu6Gu4EQyJE2VUq5HKKzCZnb1v3vSis1jJ3jaxEO1cKTw9eCMNySGzt/KsHN/dI/3zFI5M0sk2BHN8bwmCBFWLrQ8/cBiBLqwkMnS7qOYsOFOMTjNmlgl3jOfls1YwcGh21S3Gh9h5jdzpB6ET1CH6ZWL7qJMCZlYQG0D0nmHKePczreHMQ+H+CsrjQdh+NlATdJKKcSQwe5AffjzQ4Y5RUD5K67Ff2n87fZx6QQH5WpVHump7qDtlMhVhRg9kiflAW4GhJdRI15NkIPXm3MkfHJcXfIy6LlxGMjCt9vPJInszeNGJnavesS95q2MgvxEMZ2GqBXq9t8lQEC41la5+k29Q/m8BRNmXpxZEs/ha8n2lYpmReglRF5eztOl1p4WsD0jT8pd0gvmnPOn0oe9wF+3KvcnPlyG4wyawIl6HJwzQ7ulmmXIrpueBPUmAgUhP5vz2xcMQLXD/ahqiw4tftkIolXF2TF4Oa15FWDSMY9G3pKH8g2XPH/tAGI0eHiyJoKe79/IFrIUaFKuQ49dplYX7b5ZH1lrUmrwZJnJAiWufvFvZigLMqnf9TKi6RTr2hXDWpJbZ5m/hUqkSzyXOW5hz+k1eAh3yISMwEZx+59rGeByO3c1AAF+SMpcZb46mWPcJTHkydcqd8AUAzveKKyZgH2KzN6A6a3Nc1QpfmMU0lrEQoyNDWF+vEs6JtAhGgLhUDPLNJ/rBY2ZjZKBm0jYXJ2rjxBbj/O/iSJNCclV7ubksJXDUcisR+9pbfNlgNrhOy+hovpQiISGd8YZZsh2ocahGbY+ch7BaLzdXyVqxAW0fjTWOAqzEL1u0= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 050b5b12-55dd-43b7-e2c0-08d9e173dbe1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:17.7700 (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: OdxDGIGhs0N3IbMTJDgVxpRi/UlVSmfl7t/V5ex5QuWIMi/V0Hyh4fG0aPtQJSA9OQH1FPTLp29DAkE5BZS/Lg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Instead of initializing the trap groups used by core in spectrum.c over op, do it directly in core.c Signed-off-by: Jiri Pirko Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.c | 22 +++++++++++++- drivers/net/ethernet/mellanox/mlxsw/core.h | 1 - .../net/ethernet/mellanox/mlxsw/spectrum.c | 29 ------------------- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index c9fb7425866c..20133daa54f5 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -212,9 +212,29 @@ struct mlxsw_event_listener_item { void *priv; }; +static const u8 mlxsw_core_trap_groups[] = { + MLXSW_REG_HTGT_TRAP_GROUP_EMAD, + MLXSW_REG_HTGT_TRAP_GROUP_MFDE, + MLXSW_REG_HTGT_TRAP_GROUP_MTWE, + MLXSW_REG_HTGT_TRAP_GROUP_PMPE, +}; + static int mlxsw_core_trap_groups_set(struct mlxsw_core *mlxsw_core) { - return mlxsw_core->driver->basic_trap_groups_set(mlxsw_core); + char htgt_pl[MLXSW_REG_HTGT_LEN]; + int err; + int i; + + for (i = 0; i < ARRAY_SIZE(mlxsw_core_trap_groups); i++) { + mlxsw_reg_htgt_pack(htgt_pl, mlxsw_core_trap_groups[i], + MLXSW_REG_HTGT_INVALID_POLICER, + MLXSW_REG_HTGT_DEFAULT_PRIORITY, + MLXSW_REG_HTGT_DEFAULT_TC); + err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); + if (err) + return err; + } + return 0; } /****************** diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index f30bb8614e69..42e8d669be0a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -315,7 +315,6 @@ struct mlxsw_driver { const struct mlxsw_bus_info *mlxsw_bus_info, struct netlink_ext_ack *extack); void (*fini)(struct mlxsw_core *mlxsw_core); - int (*basic_trap_groups_set)(struct mlxsw_core *mlxsw_core); int (*port_type_set)(struct mlxsw_core *mlxsw_core, u16 local_port, enum devlink_port_type new_type); int (*port_split)(struct mlxsw_core *mlxsw_core, u16 local_port, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 4c6497753912..0dc32c23394e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2528,31 +2528,6 @@ static void mlxsw_sp_lag_fini(struct mlxsw_sp *mlxsw_sp) kfree(mlxsw_sp->lags); } -static const u8 mlxsw_sp_basic_trap_groups[] = { - MLXSW_REG_HTGT_TRAP_GROUP_EMAD, - MLXSW_REG_HTGT_TRAP_GROUP_MFDE, - MLXSW_REG_HTGT_TRAP_GROUP_MTWE, - MLXSW_REG_HTGT_TRAP_GROUP_PMPE, -}; - -static int mlxsw_sp_basic_trap_groups_set(struct mlxsw_core *mlxsw_core) -{ - char htgt_pl[MLXSW_REG_HTGT_LEN]; - int err; - int i; - - for (i = 0; i < ARRAY_SIZE(mlxsw_sp_basic_trap_groups); i++) { - mlxsw_reg_htgt_pack(htgt_pl, mlxsw_sp_basic_trap_groups[i], - MLXSW_REG_HTGT_INVALID_POLICER, - MLXSW_REG_HTGT_DEFAULT_PRIORITY, - MLXSW_REG_HTGT_DEFAULT_TC); - err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); - if (err) - return err; - } - return 0; -} - static const struct mlxsw_sp_ptp_ops mlxsw_sp1_ptp_ops = { .clock_init = mlxsw_sp1_ptp_clock_init, .clock_fini = mlxsw_sp1_ptp_clock_fini, @@ -3666,7 +3641,6 @@ static struct mlxsw_driver mlxsw_sp1_driver = { .fw_filename = MLXSW_SP1_FW_FILENAME, .init = mlxsw_sp1_init, .fini = mlxsw_sp_fini, - .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, .sb_pool_get = mlxsw_sp_sb_pool_get, @@ -3706,7 +3680,6 @@ static struct mlxsw_driver mlxsw_sp2_driver = { .fw_filename = MLXSW_SP2_FW_FILENAME, .init = mlxsw_sp2_init, .fini = mlxsw_sp_fini, - .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, .sb_pool_get = mlxsw_sp_sb_pool_get, @@ -3747,7 +3720,6 @@ static struct mlxsw_driver mlxsw_sp3_driver = { .fw_filename = MLXSW_SP3_FW_FILENAME, .init = mlxsw_sp3_init, .fini = mlxsw_sp_fini, - .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, .sb_pool_get = mlxsw_sp_sb_pool_get, @@ -3786,7 +3758,6 @@ static struct mlxsw_driver mlxsw_sp4_driver = { .priv_size = sizeof(struct mlxsw_sp), .init = mlxsw_sp4_init, .fini = mlxsw_sp_fini, - .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set, .port_split = mlxsw_sp_port_split, .port_unsplit = mlxsw_sp_port_unsplit, .sb_pool_get = mlxsw_sp_sb_pool_get, From patchwork Thu Jan 27 09:02:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726433 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 59510C433F5 for ; Thu, 27 Jan 2022 09:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238134AbiA0JD2 (ORCPT ); Thu, 27 Jan 2022 04:03:28 -0500 Received: from mail-bn7nam10on2083.outbound.protection.outlook.com ([40.107.92.83]:9601 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238164AbiA0JD0 (ORCPT ); Thu, 27 Jan 2022 04:03:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pt27uwc0uk5ewsbbof7pjnIPhhydrl4sYAQE05TCNIcIQ3LKOP9PHCBc8GhD1FRUS/e7vYQObqPJaWvzX7RmGBEunXzT6U9oFEfe9EZMJLav46dSjaRQB2VwC2gcxnDYQBM1ffJ0Gl/vdna9P7eufNIC7NlC/B8HIsw93DpYv6lw8nUpduTV/dE4vnpfCWukn/MfV5V9cIQDytV2CwnEuZAJfr4R7bxJVpYhYEEREwcCUZd7f0g8I/CuA9r+KT/Z+98/me8RGEER6O+uSB0QsKDULu62hhBG7W1sJecW7iipQ86w9XgIgQvdWgRE9hzYmo12BpbynFv/aEI09qHjAw== 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=dyIslcu4MyhucKFA8YbijSdiZPFSzMRGL9LSpC72x8M=; b=PW0H7m8H7BoB2n7UnCOsHZ0F23C4fMW694XtBm1EKjIqbAbbGUSb92hIZdXSTDdEPhsyQpOK0BAa5mlEbFjUwFV0v0LgcfLgOnAGsgosx4PDYHPoHW/49mQQ6k2PQaPwcTAxCOSNGpwaepvHwVdN2BRh7ime7DMiEDbuHNber0uZPlIcjjBjwgJzCVPkIwhCB7po479U30ygxj9uu5zADyWY4Y4I5lZ/snI1GGBHOmTyaICzst5zZfxlizzH7lvlClWVHLEk723eWdXdmYEjN+Vc5Ktlr0iSyOOBinmmBnnG6T3xgoy+5xG07aCOGdbiUCMpAuOfjpMNOTvL7mKW9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=dyIslcu4MyhucKFA8YbijSdiZPFSzMRGL9LSpC72x8M=; b=ari3eajix1B2l7w1Op223UyrggvtMa8axGew6t5/UEV+07aEDh2PCFUdOC1ufb/b8CU5AS17y87HC6Rfg4uHpdbod/e829ODMz6746XrOmQBz1FWu15RYeRDlT9fIj92X2MWC8jkOrfhM+HKDXm1Syc+cTxoS3rsarq3UCQ26kdIxPxFUPk2g4YmZw1foOlSv+4hP5Ab2V2CNYMhkvUEhM/2jYNtrRduwE+pKC6n4yJvhPEzU4nJhEMryylpPWxV8tCHm3CRJmAPC/YyOOo1KcGtzjdHlu+MIBGjPzfo9WNPa187Nu+zzcuEvNP+JPKk3NBefJW3nezg+3i2fvwwzw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:25 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:25 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 4/7] mlxsw: core: Move functions to register/unregister array of traps to core.c Date: Thu, 27 Jan 2022 11:02:23 +0200 Message-Id: <20220127090226.283442-5-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0261.eurprd07.prod.outlook.com (2603:10a6:803:b4::28) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d049a45b-b15e-48aa-39b1-08d9e173e01c X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HUMo1knjwfx4ETkW1OVOGRLgjM9Nj3w12y0tRp8oyWQMA58hxTXF0yKcSR4XQQfMbePZinzYeYkelmOs/IETurbdyDgy9OlnxrT2g9YAmFU9TCIfnMJHIsjpY+q3n0n1zlpWDkB4q6+bJYYMLuzbqgZti+z81IEh8n7+eGF5Xt6pVnkWqfd09AUQWysvH+vC+/QeeHFRJmmA9Y7xcC+ZNoTJym/vMUjm/Bkf/qulIZdVe7sINkclHHYdVg/8t1PFryTw1TFpfUqrEF6MeXvim6HRjF79EfkKQ8BrfQYxc9o8vgrZO/ATULeGvgtdLiPqQg/5V85bC9TbEGTArWUSaIlSVIdxdjhaoL1qyZKc1iiKwEz6+QV7OrhlftYLoT3Z8mqs3yPL01NK+QNT41QYKGanWTBpSK5hdrCu2B5rf/a7WurqEEopGVwT/3+2093yTiPLAtYqKlLdjz/zxWkObY9gphbIaKIFzKBX+3BOhYnWsQ3A9RSWQ/ga7xjx8iyYaHc9J4gJ7Ldjg4j3ggSlx1+EhpLBQUXktWipTS7653q2UAklCUw52fIl/u5bfEZFmRWal7roSs5SCGKuZODKMnYLrXfzOjK4Av14mKIX5eWoofSEXUoTV73WYtAxzmypv5BA7EOj8ymbofT+k9wMBA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nVTUlyebC0/7Z2PzAmz6M8QYJvCUgwbL+wOv30w+XTUGMGrhxgB1Nfw+xcUwJbAVEzRqH99Kv0CdHhKZz2ixHYrWQUizoo5I7KB8ZWNCulJgV9q6KNC6BHD2ti7e5+CaCaFTW6GvvWAFuzz1xVNSWfqqd4W5X4INPdifrzUROe1YGKhv+yjb/y87kfoG2mDLmAF2ttkUnqGrYbjaje8VM29w3PrMAi9hiFhuU27niSdzzyPCHzcYIyWnnU3kT+PO50sKAZEzvGfZ3NBKHxnQm+Whkdz7ag10eeCjqxzTk08U4FSfH9bFjDUaKNgyvls/VQyXwVx8nf5iG2KrW1LjfHky/oKGi5R5l8BFBzcCRglxeYuCULEFrZOyqPCvegz4gfTzgvdsonfE+oFIXfyqEfH/0u/xuK2T9a6JN/BiJuvnKffGw/4rFqGXT2ZIQ7ck5ZLToN3cKlnUjU6yxrcvV3xoGACuSI0A5HjGD7pct92z4cnKjN3aHjzWBHRHEjSUUtSzuTq1IIUxmlAUpofzvK7C14UJ+wOqrJb/i4cNCPC1/vgDuHSPbFYDVIHq23AVpG+eQyEfuxiYx8yqnugkSwDt8L0mCQDDFZstpY0684RVw4IyzWK1ZcnvWbRso6zDW7ErJrehRzFeRnRDHjIM3L0pQIb50KwlgI4qXnyq4hB24QRrzb0KLWs31M2Kp/AKxZ9Tvxk/56HkCPkXaJ/3HzMTj/6cMGJunPXZEcFV7Glq7doSMHvU3KolKu8NNlBcloox8zNNPvr9aDhO8f/7IERt/URfC2HZ6VGBmxqnPeIFsFcZ4XdQVxTruLQlwf2pgJX0jvX98fbx4bm4N03y3I3jMI9L9iiFvx06vuAJCovzxngS5g34ODB1ZcYtUAklKfVqzXr0YTJ39ODdl/kKMqitl26R2wlmf0AqKQRltvY3foPpVqsE/4W++XXQPeZvHXyzGMJX4+DePk5CE4FeB+pjD67nXsK9+W4QmWTmGhXD8Y2frdfALuQokHoYBffy21df4EGkCYKGmsmEIlIwi5oECZgGHiD6S+5VmPfXxQXFAHJ4ueGexw9zuAGRRFXd3m5qdjleHOah6PCtvbHIODiaG0szTBqUA0zJEPvdy9+nkTlJSA/6Trve0InQ/qVDX2DolBTeTGMwFRs7JQfsovXm08Q+AiwzKg4rPscQfeNjZinIVdwpitkJzRt0eISyI1i6nQAPjreRqsgScAgu8hC4UTAc8o6pQ1Uu+M19qiD1jHbRlfVRE/WWTwqWDo7uEzvc6hJ4a+fqZXIGPPsdubiBI4LQtBmXhXqAPe4tFyd/brU557vbH2K+Xsmg9vvzxRFf3kFk4nGYER3Fiz/zBcGENfxIaUyRiH9u9F4ASzEsksQLB6kJdiaroBfy6iZszWOE8YAbQYvGC158385eVlcnBidUVDkpJRFsVlpc0jYjgs+8fD5PCj3Pezn5+uwncRcSajhCbmSMi6xSxFsKIAk5G7kAwm92Qc3L2GtYC1QgeG/kh+gXtg2seu5BJm2FJBNpXyObFo6ORHuhL0v5n3jYGB2zDvlBNWf9lFioPoBQZ4Li/y2NbMVPvbqAZHRXobHMG4ML45Mb9TnvcobMVOuYNeIvaefBDXFofjz2ZT8= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d049a45b-b15e-48aa-39b1-08d9e173e01c X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:24.9882 (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: NIY/kTve1bmIAN8b03hOL2R0BOBwGuOOKQUrXVkeuR/ut31+l97uHO+xmOaMZpRKYHzaa5Y8Y5wwhsHW5U7ZLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko These functions belong to core.c alongside the functions that register/unregister a single trap. Move it there. Make the functions possibly usable by other parts of mlxsw code. Signed-off-by: Jiri Pirko Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.c | 39 ++++++++++++ drivers/net/ethernet/mellanox/mlxsw/core.h | 6 ++ .../net/ethernet/mellanox/mlxsw/spectrum.c | 62 ++++--------------- 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index 20133daa54f5..0c2e0d42f894 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -2564,6 +2564,45 @@ void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core, } EXPORT_SYMBOL(mlxsw_core_trap_unregister); +int mlxsw_core_traps_register(struct mlxsw_core *mlxsw_core, + const struct mlxsw_listener *listeners, + size_t listeners_count, void *priv) +{ + int i, err; + + for (i = 0; i < listeners_count; i++) { + err = mlxsw_core_trap_register(mlxsw_core, + &listeners[i], + priv); + if (err) + goto err_listener_register; + } + return 0; + +err_listener_register: + for (i--; i >= 0; i--) { + mlxsw_core_trap_unregister(mlxsw_core, + &listeners[i], + priv); + } + return err; +} +EXPORT_SYMBOL(mlxsw_core_traps_register); + +void mlxsw_core_traps_unregister(struct mlxsw_core *mlxsw_core, + const struct mlxsw_listener *listeners, + size_t listeners_count, void *priv) +{ + int i; + + for (i = 0; i < listeners_count; i++) { + mlxsw_core_trap_unregister(mlxsw_core, + &listeners[i], + priv); + } +} +EXPORT_SYMBOL(mlxsw_core_traps_unregister); + int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core, const struct mlxsw_listener *listener, bool enabled) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index 42e8d669be0a..e6973a7236e1 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -181,6 +181,12 @@ int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core, void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core, const struct mlxsw_listener *listener, void *priv); +int mlxsw_core_traps_register(struct mlxsw_core *mlxsw_core, + const struct mlxsw_listener *listeners, + size_t listeners_count, void *priv); +void mlxsw_core_traps_unregister(struct mlxsw_core *mlxsw_core, + const struct mlxsw_listener *listeners, + size_t listeners_count, void *priv); int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core, const struct mlxsw_listener *listener, bool enabled); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 0dc32c23394e..a3f95744118f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2393,45 +2393,6 @@ static int mlxsw_sp_trap_groups_set(struct mlxsw_core *mlxsw_core) return 0; } -static int mlxsw_sp_traps_register(struct mlxsw_sp *mlxsw_sp, - const struct mlxsw_listener listeners[], - size_t listeners_count) -{ - int i; - int err; - - for (i = 0; i < listeners_count; i++) { - err = mlxsw_core_trap_register(mlxsw_sp->core, - &listeners[i], - mlxsw_sp); - if (err) - goto err_listener_register; - - } - return 0; - -err_listener_register: - for (i--; i >= 0; i--) { - mlxsw_core_trap_unregister(mlxsw_sp->core, - &listeners[i], - mlxsw_sp); - } - return err; -} - -static void mlxsw_sp_traps_unregister(struct mlxsw_sp *mlxsw_sp, - const struct mlxsw_listener listeners[], - size_t listeners_count) -{ - int i; - - for (i = 0; i < listeners_count; i++) { - mlxsw_core_trap_unregister(mlxsw_sp->core, - &listeners[i], - mlxsw_sp); - } -} - static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp) { struct mlxsw_sp_trap *trap; @@ -2456,21 +2417,23 @@ static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp) if (err) goto err_trap_groups_set; - err = mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp_listener, - ARRAY_SIZE(mlxsw_sp_listener)); + err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp_listener, + ARRAY_SIZE(mlxsw_sp_listener), + mlxsw_sp); if (err) goto err_traps_register; - err = mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp->listeners, - mlxsw_sp->listeners_count); + err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp->listeners, + mlxsw_sp->listeners_count, mlxsw_sp); if (err) goto err_extra_traps_init; return 0; err_extra_traps_init: - mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp_listener, - ARRAY_SIZE(mlxsw_sp_listener)); + mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, + ARRAY_SIZE(mlxsw_sp_listener), + mlxsw_sp); err_traps_register: err_trap_groups_set: err_cpu_policers_set: @@ -2480,10 +2443,11 @@ static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp) static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp) { - mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp->listeners, - mlxsw_sp->listeners_count); - mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp_listener, - ARRAY_SIZE(mlxsw_sp_listener)); + mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp->listeners, + mlxsw_sp->listeners_count, + mlxsw_sp); + mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, + ARRAY_SIZE(mlxsw_sp_listener), mlxsw_sp); kfree(mlxsw_sp->trap); } From patchwork Thu Jan 27 09:02:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726434 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 AE1DFC433F5 for ; Thu, 27 Jan 2022 09:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238173AbiA0JDf (ORCPT ); Thu, 27 Jan 2022 04:03:35 -0500 Received: from mail-bn7nam10on2043.outbound.protection.outlook.com ([40.107.92.43]:49601 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238164AbiA0JDd (ORCPT ); Thu, 27 Jan 2022 04:03:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i3GDYUEQuB4r5n9zxF9tqxG61X8O72taum8dCFqf8QFqWIylXVL69Mn3/9QsztLdYsmUqAQasEx2sQW+2py1Rm3b/46IfPdRhn10bODrjS5bGNgtiN434lbyMne80Ut0BHsErwPr0DxlkzJP4Y8XiuXm5vB7R0hr69GCz+2YYRfMSeV+ixx/6kAgGYqTuzAOAcHDUmYSY5Wo9LclF5ooJJHnrBIQ05eP46OPqs0O8T602J7ZJ09FAP+yJVAsl9FIF63D2m/2VRi2KZTKQipRjzfL0eMHlUUgxvxQAlZ4pxJBVs9fDMlKjUfcsWrN202wyuvMob88Xe48fKesGnzVZw== 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=CWq4NZCVa60N93b6wJVJFqiAQ9zTFsW/zXW9Iq2zfGg=; b=NgtJrayx/a8WhMwsnoTN1xAx9spfFrut+L07MYO71jtDRNx/NysyTQsd5RJpNHuwIZoZO9BDl7wgVejIR0na7lukAne/WE4iJcWzHDpecF1+J0Tn8DB4JIL5PivvB5S1cYBJDgoaY5HFnK8AJ94yiyByO9jev+zHdfGky+A2a72WIG+DoFCpgoZZERmlk755COWBv5K3pWUpbI1tsBCwzixJYASeMPEHvSbPIiMCwF1CuBUoBJHxIOT+pZfsDRgXOWq6xBAhcj19DkQZN/VCpPnEu6SbzlLnQ2BuMEohUTek7+lJ15Tv3eZmoMy0xr1giX38tGY6aG1oXdDTxmctKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=CWq4NZCVa60N93b6wJVJFqiAQ9zTFsW/zXW9Iq2zfGg=; b=Ya9rGNAFCATmoSPQb7aON1bjI/dpYkDS6XOulnCiAERN0Ed5Fuaff01S/tzFhnzxLQjidzN+fpwyZ8003ihDagTFtwD63+QzRAndCZUd3GLe9andv911uewTi9U+9jpFf59ryOKOL/MyVm1obmjZ1R0S1gEB9e+qxe2exls1M12vfOrQNOXiPPernKj3UIFzTyJA5LVftgHUblX0HCYcRVi+olodhlfPPwxVnsqGLoT3/Zn/n+43F0zEmCbiSG4920zfELRGc0PINJvUMC2MjrE/OLNhVItUo+fXZwv4pvtUtwz8DC4J/WdIDB+LWY9Q2kvLvwDf0x6aF5/201xvoQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:32 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:32 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 5/7] mlxsw: core: Consolidate trap groups to a single event group Date: Thu, 27 Jan 2022 11:02:24 +0200 Message-Id: <20220127090226.283442-6-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0262.eurprd08.prod.outlook.com (2603:10a6:803:dc::35) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5af92773-de4e-4da6-b580-08d9e173e47c X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RQWn/jE4H72VAK9/6rClXyynfkaHCKv9OFd7+1ZhLOzSC5dWDXvUxXoeGCas+faBE0vP7ZvvpAN7SX3p0WIkb/mPjwDoaPQ2XVd0YH64OqT9s5NkGh0cwwqIq+JqcTuivscIFGE5SJNTYqKHN4HLsJjm3W+Y/s3u+IHHM5Du9DSRJ6d2FqqBHGimivxxwVFAxv9t7l2g5DS01/t97tGONYhauf10BwpRWCw8p15tFuDuQS5X+lFdN91eXHR4xkXyrFgm0tVUqXSfhNtRweDpSmtLVHSOWaEYW+5z5LBn9DKqaNExSeP+v1wpgd42F/alGnIjqqKzcBhcDfHzhHfEJ2dhkSwdGQ5TQJ22nsM7+y5RdR0A2h6crUuAfA70BevkbCjw3M++uvcThrWQ+Ps/apc//2s+fWTsz70ue4wfYqA4vs5GU/lMflN48ZAV2gqMZE1DUKbeeCcEbHityInvLBbrgYL9X6O/nCmM4imh+ikL5jcM1Xi5op5CC/KjOcu5LzGOc/0eYAwwJGk8lnxa+H7l4B5aRpWJqOcDXzlagqB1gY358iMb/8vLezUUi0FeQ+7svtPQEVl2gNII/94oGaqsPnFETW0rPExOizNy4WWquW0GwsShfluuGnphK9l29k+dNzAumdx9Girnpe7m5Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(6666004)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FA3EyFVTZEbPEXKRnHPldAaFtRxHmO84L+ydeLHiWB94Qh7khRc0ODBLuZKlS9NgrSOBQ+AgY/br+DJbURL73aOaQUxqeFeWrVYECZKsaxdxULMG2JEy2f+X5nLKA0qh609QX5AF5g46vNyvO++ELi3bfyuWA+gGVVzJl+5L9dc2fH7Ulj6FDu2cbpLD2MRTqw6hM9SphkAI867MtsxBpqgs3vmDkJf7tCI0tQ2Wr8dzsMlW0AfSg1VQuy63s4qRVtk8trEkPkqYET9Bcqwd61eUBPjKDTyQT5ODbzYYc/PpFrX8ihqzRwXr6xmeVUj8gBt6CkfbeM0NhQPyR4vnK8sWT3XBcs162F6r23VHCCym7iYsNVVio2YLDe+7kd0I0We4LDQCBm6ELwL6FJXsJheff1Um0RKrEu8MmZUv0HiDlcmbeTpZCri+eb/h+1aL2wl1FFBM3aqlM5E1mftILiyoDqqmXfLJSWOaqNH+DkIBCU3pChTSXFgN47fvpzVgOQTqM/vzHY75kM5Z2DTFcOXywngL3gM8e4KdA+jGh8SnfKIsRhr//a18oGrxDY2/8S2dBPb3HHbhH7zOfZkFe7qWUm1GM2WPsk/Bc2U41dWKYE8og+rV+RaMjrXgw8NG7DSxzz79v199pPkIz7scCGAilUxBquq31s6McawbDlaCNBtrCFEIiL3C2+qtVHlWqGOwwsSNMpMCL0QI2CoKzImtMKxpJkju6Mt+P/ODMC33HOr+NwLy+L2V0RcWI/fuC7nvOnDB50Km2Hw3On8M3+iVFxIXhRHphBie0OllylZxTAFhCyCZ3QIpU8kf3YOeAkT4G9lb9VkXqPiv4FaEKlKg7735XXFQMnunAHB5XxsUHhNFf/WctpxeRsFNOnQZJ9Lm+PLe9dHoEdzNbIKyW7VI6ksXbLdFz7SWRmEALhNdwpHCv0ISgpvTydS6YkLUDxnoG3NRmdH1zLn2BMrTSuTH16CFlnBU46YasfrAj302KxaugtLVLRlu42c1AOV0NjgaFRsFhbjUiwGfD1L8G3zMGXqsShS12MYa3ZEQlwrgIOmFej3QIiJozGOgfbDq6khbZJEWIi4h68lW6B1YMOz1RhFqf+HiJlTDd8Qmcf3Bex8Ai+6ISxJnyMHDKyDq15CLlMaKK9G8sE4qZSP6rQ5bi57ZhN3sty7YhfizSX/gO07yAnXKYF+OxEI4uBAM6/n1915muj5XzbgOE8ZvC9BamKopww3/79nymYnXZrOEly2ze7vNftp45D+b8De2xGCgp8QdKMpjXrk0Td8yU91JqKiUpljJE6zzb/tS6UV8sCaw2ds1FjUDdTJT2ihA2XMlVOrNp3XczNlwZil2JrkmUDcipyJCgpYH1gCc4GKZgotwqSKg+C0ljdt5iVMc4WoYbZKfBt3DGSDLWwgL8ichSc+ereJpSAMdp6yG93EBVNkcm3bJFfcPWTozXZzlA/CN8Bw9Y8Rlfh+UKeHhan6ZU6KAbRiuTpZFMOe6UsoYB7jCAq0NLMvuDp2rAbIN6LouOXZghGhy0RW0ceVx+9K1ID9obh0nQVtolw/hatPbPviZK8ZnMCDfiZ6fxX4w0k3pJCNIH5gULJZya0d807d2wT67sPomf22lmrikJeg= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5af92773-de4e-4da6-b580-08d9e173e47c X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:32.2689 (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: 8/JqUf5HNljVqrd9faW2mPxPHC3rdQe2OKLvUzhFU9pz1GyCfxIsvG5GGONQh2Cuw8sssE+sHnksDDgTIiUfJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko For event traps which are used in core, avoid having a separate trap group for each event. Instead of that introduce a single core event trap group and use it for all event traps. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++---- drivers/net/ethernet/mellanox/mlxsw/core.h | 3 +++ drivers/net/ethernet/mellanox/mlxsw/core_env.c | 4 ++-- drivers/net/ethernet/mellanox/mlxsw/reg.h | 4 +--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index 0c2e0d42f894..f45df5fbdcc0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -214,9 +214,7 @@ struct mlxsw_event_listener_item { static const u8 mlxsw_core_trap_groups[] = { MLXSW_REG_HTGT_TRAP_GROUP_EMAD, - MLXSW_REG_HTGT_TRAP_GROUP_MFDE, - MLXSW_REG_HTGT_TRAP_GROUP_MTWE, - MLXSW_REG_HTGT_TRAP_GROUP_PMPE, + MLXSW_REG_HTGT_TRAP_GROUP_CORE_EVENT, }; static int mlxsw_core_trap_groups_set(struct mlxsw_core *mlxsw_core) @@ -1725,7 +1723,7 @@ static void mlxsw_core_health_listener_func(const struct mlxsw_reg_info *reg, } static const struct mlxsw_listener mlxsw_core_health_listener = - MLXSW_EVENTL(mlxsw_core_health_listener_func, MFDE, MFDE); + MLXSW_CORE_EVENTL(mlxsw_core_health_listener_func, MFDE); static int mlxsw_core_health_fw_fatal_dump_fatal_cause(const char *mfde_pl, diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index e6973a7236e1..6d304092f4e7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -163,6 +163,9 @@ struct mlxsw_listener { .enabled_on_register = true, \ } +#define MLXSW_CORE_EVENTL(_func, _trap_id) \ + MLXSW_EVENTL(_func, _trap_id, CORE_EVENT) + int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core, const struct mlxsw_rx_listener *rxl, void *priv, bool enabled); diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index 4e3de2846205..6ea4bf87be0b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c @@ -825,7 +825,7 @@ mlxsw_env_mtwe_listener_func(const struct mlxsw_reg_info *reg, char *mtwe_pl, } static const struct mlxsw_listener mlxsw_env_temp_warn_listener = - MLXSW_EVENTL(mlxsw_env_mtwe_listener_func, MTWE, MTWE); + MLXSW_CORE_EVENTL(mlxsw_env_mtwe_listener_func, MTWE); static int mlxsw_env_temp_warn_event_register(struct mlxsw_core *mlxsw_core) { @@ -915,7 +915,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, } static const struct mlxsw_listener mlxsw_env_module_plug_listener = - MLXSW_EVENTL(mlxsw_env_pmpe_listener_func, PMPE, PMPE); + MLXSW_CORE_EVENTL(mlxsw_env_pmpe_listener_func, PMPE); static int mlxsw_env_module_plug_event_register(struct mlxsw_core *mlxsw_core) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index aba5db4bc780..eebd0479b2bc 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -6141,9 +6141,7 @@ MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4); enum mlxsw_reg_htgt_trap_group { MLXSW_REG_HTGT_TRAP_GROUP_EMAD, - MLXSW_REG_HTGT_TRAP_GROUP_MFDE, - MLXSW_REG_HTGT_TRAP_GROUP_MTWE, - MLXSW_REG_HTGT_TRAP_GROUP_PMPE, + MLXSW_REG_HTGT_TRAP_GROUP_CORE_EVENT, MLXSW_REG_HTGT_TRAP_GROUP_SP_STP, MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP, MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP, From patchwork Thu Jan 27 09:02:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726435 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 BFA52C433EF for ; Thu, 27 Jan 2022 09:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238171AbiA0JDl (ORCPT ); Thu, 27 Jan 2022 04:03:41 -0500 Received: from mail-mw2nam12on2048.outbound.protection.outlook.com ([40.107.244.48]:16065 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238167AbiA0JDl (ORCPT ); Thu, 27 Jan 2022 04:03:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OYXj6yuxxJ6SmFYMQp544iiD7vmkQ+JLaHYvsGH/gb26PrJ3r4DZgVwGzki2BSa9sjNSngj58BbuQXg8bLOJOptrgcVGfrjGMYgnHthmiAJALdemEzwXQn+/iZFHV9THemtFtfv6WOuTWhvkM0ziE7xSadD6h5BxbCNWgme0ldrc52ri+OmI5IRdEcoybNtGz8L58E53dNXpViGpiLB34t2Trdy7klrVCn7TEnsgD9UeOPVy10Sz8+Qxe086oVTX2a1zOncocZb8WZQ5EEnZy31Q8d1HKkgmHHn+bMZnfRCu9APQrV1gBdv4zimTiO/JDiLB8+Uhj7wWfqu3FvxOkg== 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=iJ6/GNy9zHQALWMhpYsvzZTt4fRZHu8jIF2uae6RorM=; b=NG+78/D975lrn0E+NnrvDMAvJg1tjaMl+yJQfc9W4vT5MDexqfPCuUnZ8Cy6cWaSdIE7lIuGh9Mqs/uyG2D8Lie/ZKmgH81iqTtdhj9qUMJzDuMSO7DSPfmLwM7YOw7+/nf09tRu64acuyXgX+/VC9KPlW46ZfHTERtsiubnMAOrw+s64nloXwtKF89bRuM5FkWTy3nNKvWTouGOfHpr3AjgDlcY3YM9GRcbqRFzLOSZSQSVDpectDIYuZpz6fsd4DcS/rOISN8beryYIwfggM9//85azg2HADzoTrUhmxh07GV1QfPxcBkUWifoef/tyJpMRdPushVSkQEE2VWNvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=iJ6/GNy9zHQALWMhpYsvzZTt4fRZHu8jIF2uae6RorM=; b=Ighks/456Hxysk7kcFzQ1qd9VJEd9wcOxz8CZ0ef/ami5nHUnbFS1WxeTHaadO0dLDz6vypA2DA5+GXrAg9PdLO3Nq1ERhafmHE49tSDGUeKJIKU9ogymCLg5vY4bzEFavI6/wo3Tv3xcMer6HpFQw0rFFyWf8pdTsFMeNeP53rKgNrlcp8VIT1Qq+Xgv/mseYk79GCnELXE4pn3i9GuRoNpMvDs0EPraqRr6T0n1lTujrpzYAIiP8JYe4ZEH27YLAz8cPcW/9j0v8lMWqTTDUXM3iEZ3E0UOatNMc/1Uc9y8OeagCXYa+LDEwh34jH+Hcu4sTpGmxdIDt//lpXS2g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:39 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:39 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 6/7] mlxsw: spectrum: Guard against invalid local ports Date: Thu, 27 Jan 2022 11:02:25 +0200 Message-Id: <20220127090226.283442-7-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P18901CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::33) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef0bdfc1-4441-4e0d-ba96-08d9e173e8e6 X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ib+Tj+tzL4JRu8TDVHEhqSbqfypQcg8NqmlJAC/gd0X2g6732Me7+KAxHZhkmePcqmy+J4EFCTaDNbZDqxtsFkhsU6aQxG83L/bjh04aS2quiCEZm581mGIYPuTKHl9xbpkJ6QRH3G0JmBVKm5wSSq3/sl6PQoNP5sRlxsYqO1x1W61L55Qkke9ICmbwAjHkAxnXjS1wCHw1OfyTsJziuH1kBfZUr2+nAe6OHDYzp9/ppsN8732sGv9C72vx0DTnIq67B4JzX58ouO5+Mm7qM7dCbL6LFQt3Qy77+yv3aWKgQhp0GrKuREEwFrv/H+Oii2RtlEOcfOqMCBpLPfupPcJKXQ6dMUlGYVCLmQuwCbkLhQpqYgk6bS0pD3+ynBZaSD0qerLKy2rWOYdIUuEFerBAQN8FcIjMqGOgY/gSSzdf/44IWYEH2tYmetjPQgVuSDKmcYXHvi8PnVUblKel1ig1OOxknXjiWDbg5qGHycnht0HKP/5flDzAJ1H2nSVPXmoftTmlV1mf00dTgqF1UM8LKmheq9aiTftbMLgcE+tF67EBV2DLMUb2c0FPHlw8iZRpwL/xA1xW9sz1JFLXP6keTmlZtr7Iz6fxSSWAae4RvNVI1XVxB4MM4K0l3UYrxIhyb9cys7cmwgVoISsd5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(6666004)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MhVfr9OHnRpHoNx0ExJdPokBtkzffWJOf3bRlWbqnntgaD3oTEMsst661YqdX/p0uo8YPEPO+xGDLBcYRn5ZTX191rIpNgrnWq3Kx8wcZBYUbQaIIu3bvDQ4+lJNwOCVJQW/aD17G/qLmkRWRnbDoFDUo/YjXP3EnSLdGLAAHLH5TCVMcGxRid3sAA3KMpDNf0dUbQjbjyHBCr9Ln87fEwunWyNqGLA1/j3Gvy73d+lBRFDWimBqjYeI2k5pzccal8O9KysH8jzp+z8UVpbPAqg2rnMBgpYVNE1KvjIj2iA7a8wBqNMuBFv1xDHjPym0LIqDp89jqQRWX2UeezIFfLB00gBG8sRgGup5InNjzF7ffaf5cQAGGVITs+QW6/akCzo8H0cNV5t9yiHkXgUY66BFMiJVXTZIy4WIdYKuYfGUKJv+e1V3pOSVRX1NAUYp6jvBAvKxkqEfUDZio5LEgNJB5zCMbWpRveSKs2ZJ852gRj+U3ZguiwhHWWT1p8YnaQDNdHdvsHFtHC8ZSrsNSM0AM2aySoEPowutykDQ+QPokXUfWkNBnijkHB9Zf+LnCLVfiXSUMHt0WrNgrpcozeZyM1mfr61rkMgZyjMlqa+XqPElIOaDJ2qy5tTZrtmLi7nd+gnahiHNuHCFU9rA4eO7kRDQSDmijXr15UiB9TdVWEbs2zPhmYHPFwwX+lTOL6iiT2ZTa6sLEYlQ5jZFgZw02wjA2qUWva4ocsznKtygvSA9lg5INGJQUMrxZZ2HOOHg/MMV1203Hsijcdawap824ymFkcMFoCV4kI1Wi1etqK0XI4pBwyPBioa5qDiCdgIzK4jFXWIcl/NthlXAUbg+HZrETvi/Mv0fJt7tiieC8r7ub4fdmyfd/Ijk3B1QWYJRx3RayuUwyE9FzQjz5P0HzJI0IRC1pj9O+EQrfBzx6t292gyJlFB2DjQjAHnLAx1bky5595n0wrYry5JxBnPk3g8+otEaBEbgA6ye28QJT5vi+NIay1JklJ0weRbK9LFNNCqiiS9YJe6MTxcdFyRUsZwDl5mg+RlL4Y/a97uWnJwxJzQDCzYQwKeT6e9vnz+FYPItkrOcWwuOrSjPeWgGDLeeu+HUxnppwR5sDNLHL5P+fDfAi+jJUCW4f4Oc3xsm3oldcuUeSw80HEtID1uZxs7hZ0PVpqPR7T4S+2GRyNqpo90CBo5sWSELExXY9WCCDsvSgezSzG4zMYMmGD2nl0Z66uO1hKeXOLI1a3eGOL9TGxzoFMg/Qhu/WUWHlLukcqSHvmSm1Xxvd8s5FpflgESGvnNR0VjYN6fDRuwOZhzj5yYKATbblj7OSjGFQxX8qMUvqaI8lDC9dysz0oq61Qqrm9KtjMLMcNHHOG5C8AKZ3OhyNYA3YNJKaxxbWQNPHUGpFNPz6DOdINWsZIPwOxafkYpmpbVUCwv0MygWHgJbx8tsk4xdl1AyOCwIxNtDOREjHxUTJvfit7dtOBVqw+84SN3OQ8NE5YJOXNp/GTkb/1AoIE75gV9yaDnGvbffkxd1MPoUJsuvQQVRYQJx96PDnqdx+wdpXU0krrJ3UNqTWP8JptqTiGrx1MjuZCyd6Wa4/4PlWZXLtHWw917BzTVE4WAir/CQQGAQUSQ= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef0bdfc1-4441-4e0d-ba96-08d9e173e8e6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:39.5809 (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: 1oBreIYQ1eP0TubNx1/EHgszq+MY0pt2BqwhKmUdNuSKn93qQFQwozrlLqJGSAA7GLCwgC6vVdkno4WEeQNQHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen When processing events generated by the device's firmware, the driver protects itself from events reported for non-existent local ports, but not for the CPU port (local port 0), which exists, but does not have all the fields as any local port. This can result in a NULL pointer dereference when trying access 'struct mlxsw_sp_port' fields which are not initialized for CPU port. Commit 63b08b1f6834 ("mlxsw: spectrum: Protect driver from buggy firmware") already handled such issue by bailing early when processing a PUDE event reported for the CPU port. Generalize the approach by moving the check to a common function and making use of it in all relevant places. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 +--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 7 +++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 3 +-- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 +-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index a3f95744118f..a4b94eecea98 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2148,13 +2148,11 @@ static void mlxsw_sp_pude_event_func(const struct mlxsw_reg_info *reg, struct mlxsw_sp *mlxsw_sp = priv; struct mlxsw_sp_port *mlxsw_sp_port; enum mlxsw_reg_pude_oper_status status; - unsigned int max_ports; u16 local_port; - max_ports = mlxsw_core_max_ports(mlxsw_sp->core); local_port = mlxsw_reg_pude_local_port_get(pude_pl); - if (WARN_ON_ONCE(!local_port || local_port >= max_ports)) + if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) return; mlxsw_sp_port = mlxsw_sp->ports[local_port]; if (!mlxsw_sp_port) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index bb2442e1f705..30942b6ffcf9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -481,6 +481,13 @@ int mlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port, bool is_8021ad_tagged, bool is_8021q_tagged); +static inline bool +mlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port) +{ + unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); + + return local_port < max_ports && local_port; +} /* spectrum_buffers.c */ struct mlxsw_sp_hdroom_prio { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c index 0ff163fbc775..35422e64d89f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c @@ -568,12 +568,11 @@ void mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress, u8 domain_number, u16 sequence_id, u64 timestamp) { - unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); struct mlxsw_sp_port *mlxsw_sp_port; struct mlxsw_sp1_ptp_key key; u8 types; - if (WARN_ON_ONCE(local_port >= max_ports)) + if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) return; mlxsw_sp_port = mlxsw_sp->ports[local_port]; if (!mlxsw_sp_port) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 65c1724c63b0..bffdb41fc4ed 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -2616,7 +2616,6 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp, char *sfn_pl, int rec_index, bool adding) { - unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; struct mlxsw_sp_bridge_device *bridge_device; struct mlxsw_sp_bridge_port *bridge_port; @@ -2630,7 +2629,7 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp, mlxsw_reg_sfn_mac_unpack(sfn_pl, rec_index, mac, &fid, &local_port); - if (WARN_ON_ONCE(local_port >= max_ports)) + if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) return; mlxsw_sp_port = mlxsw_sp->ports[local_port]; if (!mlxsw_sp_port) { From patchwork Thu Jan 27 09:02:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12726436 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 A61E1C433EF for ; Thu, 27 Jan 2022 09:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238172AbiA0JDu (ORCPT ); Thu, 27 Jan 2022 04:03:50 -0500 Received: from mail-mw2nam12on2077.outbound.protection.outlook.com ([40.107.244.77]:5856 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238176AbiA0JDt (ORCPT ); Thu, 27 Jan 2022 04:03:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lAw9s7ojWHkeraa1MWwbGCBg1aWg/pRcVKx1pvHCvwlrB8rB7vCgYwY6EnkulDoBGbZUDfxDCAX9qHVRND16pSDVuk1p70OzRBfs9cazaK2RD/g0z/FVQG4uA7eRfv/LIoB03eaclBUwr5cZX/Hf3sEEaZBK2hwO93ApFBiGczAz0z76xnTGJatpWLLZRCS/5qcBZpVI2+lZvnB4p8RsnXkOh1veCpXvTEYdFMK7P/DWXBvDFlVxbO89i+xZyissdJvlaYV9GzZA/jhKUqXGm5XOwhCBgeAMyVgzljDGvgyngiYTNlaLbpb74zyUuquMaqmGiJKTck2gq5DciOtLHQ== 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=eY0JjPZiFVm+7jzV7pxf3KHeXeLlC74bpNq7jCA6EoM=; b=MtrPQITV9zK19GK6FiAyzwYWna5HvWe1PakwD/n6tTLbr311pmO/8ICoFgphFDkezRYCtPKzQxfmDyM9U6e8WmZf0ugoGt1tK5iwyj9YBuykaL5lEq94PmZJLKlEwvbqoy9VGbM5slRcDRDZRHq4CSkuX0O+oBHwkdRqubjpERon+EdysvrCfDTi6GGDoqVnMi3Q4CF/5dxUm8HCxEFC3nJ9JBSHNt227R7lUJhK15w6EUhSBabxiOCD5n5LWeM+atqFexaKO6ivF9GJIc12LvpIwgTfK6m0f9zWlrdPWl+hR+TNkJP5gsE7I/uzL3gsKGyQQi+tj2VjBQzidmFR2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=eY0JjPZiFVm+7jzV7pxf3KHeXeLlC74bpNq7jCA6EoM=; b=E72XSpOHZQBEnyJxz5twXTwd7aAyoTEc31f7QzEBeznNXSZzMBXLPCU3KwQgkMsbzO3am3i+iQ1U6BMv82KWuAPQy/EZWZEYrMHwdKvcrIVgAt7j/ay7vaPSpPnI3dBy+/IF8xC+O6thp5fIZQvDUwpPtWS28+lzUcAAF9UjERQZlnQxzfPIu+TLFLYKOyHsB/1+kikiEloTNcu003CF+vzsi869FX0i1wVWVdRt0tbEr2fhs85PI/Nkut49qmOdiUQS4Goo3bxnqC6Dv/4GFC5qwdyzWrrO6CGvL7/KBsGgTg10QI81KTcDYf/C5Gpf0r885GQkKKLAlL8LF0/Oiw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 09:03:47 +0000 Received: from BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561]) by BYAPR12MB3527.namprd12.prod.outlook.com ([fe80::3dfb:4df1:dcf1:4561%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 09:03:47 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, jiri@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 7/7] mlxsw: spectrum_acl: Allocate default actions for internal TCAM regions Date: Thu, 27 Jan 2022 11:02:26 +0200 Message-Id: <20220127090226.283442-8-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220127090226.283442-1-idosch@nvidia.com> References: <20220127090226.283442-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR09CA0073.eurprd09.prod.outlook.com (2603:10a6:802:29::17) To BYAPR12MB3527.namprd12.prod.outlook.com (2603:10b6:a03:13c::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf892c39-e40a-44a3-71db-08d9e173ed42 X-MS-TrafficTypeDiagnostic: BN9PR12MB5355:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zd5RYNxT/YC67xXCkjHbp7QVB60QkTzsu4c9VrUxST10jDEALlE+3MwJv+JsBeZeyxrkuGIhYzCiTRpot+7iDqgyfK0gM5Z7B2tsSXhsFFhmAGqB0AxQ1V7oZVauD7G5vKOGH4qOAjUaT6JNLTd8CM+h80M0a2Fo2v2g+ZO2lnDmKWE3CXp6WgsDXKIXvs0RvvI/er7tQVAvb9WTSBd48GDY8EeI5hSDDTVjFmy5iY2mC1JA865qj79TUowYhckI9/QhHgZTOKNJTv3HmV8/0L+A6/1QHkrwhvUtApnPeFGyhLh/h7xV8nY0E2Q/8B+XWJVZk0Te+/gPSh4+qqTBfOWPZWc1UyaZG8NYMvKbKpZgW/0y0OksXv1E0GQTHb3Z4ZmZhkA22xaDr6um1H4JAzU5tqP+pcJIsFeT5ka+RbGZsAJrmhqHx++1HeTWw0/WtwnJVLUvGq3wZETzd6W5A2yeWPvAIkpk5qlxx/uRqw80gBMZEuJHA69lY8NLUpp/tkOCCFadh970PnFZwVGGYmCsmNxg8vI0d9fWPuChsoerLP6YjlhTIjRn9astqwulK/v7yQj7arwlJJ8MPYhMdmm8bZpRYc3xFrB3DJv5ZOF9ROj9Bdeo3m1IWLzMOZfdRFpC6K/Ve5pAknX0PYVFWg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3527.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2906002)(6512007)(2616005)(6916009)(4326008)(8676002)(316002)(6486002)(66946007)(26005)(186003)(86362001)(1076003)(66476007)(107886003)(508600001)(8936002)(6666004)(66556008)(5660300002)(83380400001)(6506007)(36756003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h1MKCs4XywehsMaKJgipK/E6BJ+gHtQGoZH8VUpmRE8HqiPUSJpTxid39+JdICIw+HvpU9b1hIjJtCsIswxuDJH5KDg/BbCbqdZuXuFQ3o6EJ0mpU4w3SLDPmbB7eR4DvklasVAbrzq4sCky3WGvv/gLIODaGZgUlBUjsi9Hk3lQ9GVZbxcBIBhX7QyDXX93sRvpwh4Ra1KwudMqm6ffZDElXpxREiRYBbhVJwPSinrSGoAR9BVSY5ObzGxj2/SM99wp5D5Q4M5tn4PtP/dEaYcd8jwWbY/RZoTpvzJmW/22YwFoE6Pp7mehtqAYbDMUA73WqCgSah6O6kgI6+jilUtauzbzbWL0VHcluW3OxDaJatWBdv3ST/jfNKunIs3BpgV2IOiL26Bc3TKaPTlXOKWo0CsN66KQDHXevlmuEnMk6ggN6GuEnwchRGs6iB+OoazDNgpElplMrW5V5CM6PzkyU15X2rK7CiW+sPCko7G2ldt0Lqo3uGmK5M7bZLcwcF5L9ttgdo0qg9VsmJoI3D84QBw+Cm7LwAQgWZsiHmuPm7nQ3Gc9HuG9KQPlucCZqfwbFs7ZlNz6plvCQHC2Kt0zZ5giQM7LQmEI7SG36nHp/NIqzgJL5gwjh/1dRzLKeMwACEyeQjkMfb2lgVyAqNn9OkE2lEQZKCN4rWIB5C+0oISz0PPep87DIU4049mua7ujtExD4NsMWQJyPmiFmrCU+wGO4qseOsAFZPCqnDIZCmLLkYbB2z9zMyj5MzdMIMOYQVfjNxzey5a4h6uMq8hGMkKi4zG0TKlgnyPS5ANYcEUWJOpRekk/O47qdBwtzINsO4WajLzXrwsfOnY/TwOKtJ9Au7RxdzdGR9nLb6oHVzlfeOH+yTpIOe88rnlUhx7vaUnXfrEcdvzOEzofSEu2Pp/VBaL07BOgQlKwM7whS1gh3ShTQCNoOwyHzGBWECe906y1v3OHtU7u6lujcJ5i6DU18WQOS4Z+oFUh4tKbcNZFHzwx9PEerGQmUn1iyLLxUo7p5co1NQywbsToMHzg1eaY9UyJpHqlDTfwx8vXMkcBtEQ/kWJhgXy7XbW8kFiuW5S0xGHdG/pAZN+Q6MfqoQctuc2xBIurvb4MRRrIkOVlNLrnpiCnz08kZcX8kENfrF8Wc3K0Mcqhw6Y+FCrbvYV5YlmUsaElRGByfXlBJmv+ikMtUlCJTPtbVFH9WN7QUMp7JqKx4EMK3HxbXWsM/R7JYaC9Vd3wQULptsVdpcwImYx1VXFIxG4U6bBo4vHoJ3Dcqbg6UIMs3r1dODW19ibizxagl0SPTU/glk9gkbcNmFArmACKluE9I8LU5kaedFkj3y0LBvEdGkcF2R4yNwx+p3i7H2AD32GaCEjh8dqAgZW4Zf2vEgfTZJov6zPJS6nwzP8HcPmEyTqvWEa0Ds7GC0DaAIhLs7ioC6lQnK9012Q2Hud0nkpwNiZ/egZ8BFYui6iXu0/LsbE5VSXY7/wIDn095JtTnacQf1IUwwfYMTUOc360NsSx0P/wIxC9ZaH1gfs4i0hnN7hL88lyyxypUy35lXJDwEvJ4eV/XZiwRP2pSdmJGQVtMKWJRt5MiLDdqX+S7pyE+dW+5srN9OzkX1yQ3JITwJzvVUg= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf892c39-e40a-44a3-71db-08d9e173ed42 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3527.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 09:03:47.0335 (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: kBjtaqhNtAIMdIA6rMMBO2DsNVIllxql4p9pa1r+saHUyxx8r6XxKgmNBAKvg1TtR2GxOOV8up2tsj2tlFGaVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In Spectrum-2 and later ASICs, each TCAM region has a default action that is executed in case a packet did not match any rule in the region. The location of the action in the database (KVDL) is computed by adding the region's index to a base value. Some TCAM regions are not exposed to the host and used internally by the device. Allocate KVDL entries for the default actions of these regions to avoid the host from overwriting them. With mlxsw, lookups in the internal regions are not currently performed, but it is a good practice not to overwrite their default actions. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/resources.h | 2 ++ .../net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/resources.h b/drivers/net/ethernet/mellanox/mlxsw/resources.h index c7fc650608eb..daacf6291253 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/resources.h +++ b/drivers/net/ethernet/mellanox/mlxsw/resources.h @@ -33,6 +33,7 @@ enum mlxsw_res_id { MLXSW_RES_ID_ACL_MAX_REGIONS, MLXSW_RES_ID_ACL_MAX_GROUPS, MLXSW_RES_ID_ACL_MAX_GROUP_SIZE, + MLXSW_RES_ID_ACL_MAX_DEFAULT_ACTIONS, MLXSW_RES_ID_ACL_FLEX_KEYS, MLXSW_RES_ID_ACL_MAX_ACTION_PER_RULE, MLXSW_RES_ID_ACL_ACTIONS_PER_SET, @@ -90,6 +91,7 @@ static u16 mlxsw_res_ids[] = { [MLXSW_RES_ID_ACL_MAX_REGIONS] = 0x2903, [MLXSW_RES_ID_ACL_MAX_GROUPS] = 0x2904, [MLXSW_RES_ID_ACL_MAX_GROUP_SIZE] = 0x2905, + [MLXSW_RES_ID_ACL_MAX_DEFAULT_ACTIONS] = 0x2908, [MLXSW_RES_ID_ACL_FLEX_KEYS] = 0x2910, [MLXSW_RES_ID_ACL_MAX_ACTION_PER_RULE] = 0x2911, [MLXSW_RES_ID_ACL_ACTIONS_PER_SET] = 0x2912, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index ad69913f19c1..5b0210862655 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -77,7 +77,14 @@ static int mlxsw_sp2_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, int i; int err; + /* Some TCAM regions are not exposed to the host and used internally + * by the device. Allocate KVDL entries for the default actions of + * these regions to avoid the host from overwriting them. + */ tcam->kvdl_count = _tcam->max_regions; + if (MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_MAX_DEFAULT_ACTIONS)) + tcam->kvdl_count = MLXSW_CORE_RES_GET(mlxsw_sp->core, + ACL_MAX_DEFAULT_ACTIONS); err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, tcam->kvdl_count, &tcam->kvdl_index); if (err) @@ -97,7 +104,10 @@ static int mlxsw_sp2_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, goto err_afa_block_continue; enc_actions = mlxsw_afa_block_cur_set(afa_block); - for (i = 0; i < tcam->kvdl_count; i++) { + /* Only write to KVDL entries used by TCAM regions exposed to the + * host. + */ + for (i = 0; i < _tcam->max_regions; i++) { mlxsw_reg_pefa_pack(pefa_pl, tcam->kvdl_index + i, true, enc_actions); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pefa), pefa_pl);