From patchwork Tue Feb 8 17:14:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12739024 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 A391BC433F5 for ; Tue, 8 Feb 2022 17:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351931AbiBHROw (ORCPT ); Tue, 8 Feb 2022 12:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243412AbiBHROu (ORCPT ); Tue, 8 Feb 2022 12:14:50 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2041.outbound.protection.outlook.com [40.107.93.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D7AEC061578; Tue, 8 Feb 2022 09:14:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e3msj3EasLbsnWw1EMGBYTYthFHzQRXqvhwfcqhFHN+FVrgpfcoCOXv3MUM4UY5N1XAFb5njnRc6gqSudj8Ty4KOMrXx+0jsChcuqF4630LNqsEbqpntsL/wQgy1DXcqI+GoB39aIsfOiWq1fUfSjW3BTjyWdu5ppKkZWHiJGT7SydxHj7iq8yOsA+vV2SqRtXYEfsoa44gsTXdpDB5efczS0A6qReeK30EPt35Gn3bgKMi3DKQNnA2pOv9u0BnmnbQQQarysoUnjj31PZdnoSBm1F+Jdu/eIoJdP378CnnN/YDekZuBL7lOOJx6YL6kEhNqzVLb/o2vOFYP44Weuw== 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=ZUgTWgtUpSUYxncI0pCBf1y6AddDiImbe/TPYjlutNA=; b=Q4cnviFFguQabyzKQAS+42+JAK5Nl04lb1fuVdPCH0cKACqS5xa8PRgwRk1bJaCe59kmGYhR7euC+q34JH4QAbS5OCiom/n1TcJr0snFz+AbHMk7ENCIRz/k/aYYFswYZ0/X7hnRo9D9M2w7CrVRdHjal0t5tS12/WUQKnkZwCVJx2DDIivL69tl8ipUIlY/ZMOUoqnFiRqkNoeBaV1Lb/L+tRzyA6WdlNwZOyn7djWSwC4xNTIaYO64mvnXkPl/ZlNhyDDE+P57su3yh0k+8v1IQJA9YlBSMVANkHUfwLpfCHQHCDUuajZyt3NNtNsYWVHSnrZl8xVTSF3KP9GJrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=ZUgTWgtUpSUYxncI0pCBf1y6AddDiImbe/TPYjlutNA=; b=rXCBsGX1O54QGSDKR2g3VleEZwSOBR7yCTZ36g4YQlpKfi1EYJV/aXDpiZmIf+UbvSdsKDodtxegTX9GIpIiDm4FYi8BcORpDSM3yfyXaJZXWo7tR/uKUgao//uCj4u61e546Cq7dkuizaNZJf4HW2t4wvyFavVzsIQ1aEyKv07RA9oJP68JrBRbKoNBXfarhFKCNgNIYZeqAuRIXkKc0ZQUrgrmRVHWj7YmAG9nSRevdhwKKuwAQXFOe/cWalFZx5BhDp8SJrelQ5jNmQ0cRpoCGu91Qm+GSOJnHB9ScNU0Tz80hYJEjvn5KROq++8tnvgtw3bPMshS64QGIF7ylQ== Received: from MW4PR04CA0121.namprd04.prod.outlook.com (2603:10b6:303:84::6) by DM6PR12MB3372.namprd12.prod.outlook.com (2603:10b6:5:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 17:14:48 +0000 Received: from CO1NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::b5) by MW4PR04CA0121.outlook.office365.com (2603:10b6:303:84::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Tue, 8 Feb 2022 17:14:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT065.mail.protection.outlook.com (10.13.174.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Tue, 8 Feb 2022 17:14:48 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 8 Feb 2022 17:14:46 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 8 Feb 2022 09:14:46 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Tue, 8 Feb 2022 09:14:44 -0800 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski CC: Jiri Pirko , Saeed Mahameed , , , Shay Drory Subject: [PATCH net-next 1/4] net/mlx5: Split function_setup() to enable and open functions Date: Tue, 8 Feb 2022 19:14:03 +0200 Message-ID: <1644340446-125084-2-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1644340446-125084-1-git-send-email-moshe@nvidia.com> References: <1644340446-125084-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9dda311-739f-4e33-9659-08d9eb2682bb X-MS-TrafficTypeDiagnostic: DM6PR12MB3372: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: h2sckm/09nneVk+vX9Z90tXvodmBRCxa5bm1jyb7HSgx0PJGy9ErbmzijPS3WAt4zdmZBvh1wOnwBGepkTQpqGbp9pgOzTarbX5hc0mBDnfee0tfjh3UhCix9gCUvQLbZ80nf+Uyn5EEvSS9mMojJMNUPBZkO55wMlkrs9wYFcmAdXjlHpIQo8QMfjSQHwk+E6UD7/e3rIs8y82pHshXkV4mGs1faCGe/YMdbcGXRK/RhR8Y+cHVKEShkDwH6BiPE5tcuAKYtByfTU+8sTUYb9YnNHviR3HbazjkLo615IZuL0sk3lTaqQxthWh3TSZqz5mFrSXBUM1CaWkFUoziwvGNdJ2pO72OxABpM58xD+q0mNIGlK5ib6LKnzlavjNpT/HQm0Ty3t2d+4vtEoFi/AqRLQ3QF1uB7ZGEo9F0HgYuOsHIYHxjJXROpdlSgK8nZBl+2PoW9yQQpB1aJXQX16Lx9rze8w2W45SNQhI1Q/fxr+6XfWpHac0i6LXDwbVsVIBakahqXLJlYNusJ/FhYu2S0M2oBrPzRnrAlTVj0SbtYquA7j3xRGymlrbyAPevMy//5inyRnb05YUhBxRijbJjbXpnliufoQKDxUnUmMbsmSaET8Z5TnfhTik8tyUl0+cRl13G5QYoP0+Mi9ZyIEMMewqJ6m4nwgJXsL5XxN1XZ4Ex8Vd2iQEA+MXUH6K6y+Uv2SRUkGSICWA1M7Fidw== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(40460700003)(110136005)(107886003)(336012)(426003)(356005)(5660300002)(81166007)(83380400001)(82310400004)(47076005)(2616005)(26005)(36756003)(186003)(7696005)(508600001)(316002)(54906003)(4326008)(8936002)(8676002)(70586007)(36860700001)(70206006)(2906002)(86362001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 17:14:48.3158 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9dda311-739f-4e33-9659-08d9eb2682bb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3372 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory mlx5_cmd_init_hca() is taking ~0.2 seconds. In case of a user who desire to disable some of the SF aux devices, and with large scale-1K SFs for example, this user will waste more than 3 minutes on mlx5_cmd_init_hca() which isn't needed at this stage. Therefore, split function_setup() in order to avoid executing mlx5_cmd_init_hca() in case user disables SFs aux dev via the devlink param which will be introduced in downstream patch. Signed-off-by: Shay Drory Reviewed-by: Saeed Mahameed Reviewed-by: Moshe Shemesh --- .../net/ethernet/mellanox/mlx5/core/main.c | 81 +++++++++++++------ 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 2c774f367199..73d2cec01ead 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1006,7 +1006,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev) mlx5_devcom_unregister_device(dev->priv.devcom); } -static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot) +static int mlx5_function_enable(struct mlx5_core_dev *dev) { int err; @@ -1070,28 +1070,53 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot) goto reclaim_boot_pages; } + return 0; + +reclaim_boot_pages: + mlx5_reclaim_startup_pages(dev); +err_disable_hca: + mlx5_core_disable_hca(dev, 0); +err_cmd_cleanup: + mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN); + mlx5_cmd_cleanup(dev); + + return err; +} + +static void mlx5_function_disable(struct mlx5_core_dev *dev) +{ + mlx5_reclaim_startup_pages(dev); + mlx5_core_disable_hca(dev, 0); + mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN); + mlx5_cmd_cleanup(dev); +} + +static int mlx5_function_open(struct mlx5_core_dev *dev, bool boot) +{ + int err; + err = set_hca_ctrl(dev); if (err) { mlx5_core_err(dev, "set_hca_ctrl failed\n"); - goto reclaim_boot_pages; + return err; } err = set_hca_cap(dev); if (err) { mlx5_core_err(dev, "set_hca_cap failed\n"); - goto reclaim_boot_pages; + return err; } err = mlx5_satisfy_startup_pages(dev, 0); if (err) { mlx5_core_err(dev, "failed to allocate init pages\n"); - goto reclaim_boot_pages; + return err; } err = mlx5_cmd_init_hca(dev, sw_owner_id); if (err) { mlx5_core_err(dev, "init hca failed\n"); - goto reclaim_boot_pages; + return err; } mlx5_set_driver_version(dev); @@ -1099,25 +1124,15 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot) err = mlx5_query_hca_caps(dev); if (err) { mlx5_core_err(dev, "query hca failed\n"); - goto reclaim_boot_pages; + return err; } mlx5_start_health_poll(dev); return 0; - -reclaim_boot_pages: - mlx5_reclaim_startup_pages(dev); -err_disable_hca: - mlx5_core_disable_hca(dev, 0); -err_cmd_cleanup: - mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN); - mlx5_cmd_cleanup(dev); - - return err; } -static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot) +static int mlx5_function_close(struct mlx5_core_dev *dev, bool boot) { int err; @@ -1127,14 +1142,30 @@ static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot) mlx5_core_err(dev, "tear_down_hca failed, skip cleanup\n"); return err; } - mlx5_reclaim_startup_pages(dev); - mlx5_core_disable_hca(dev, 0); - mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN); - mlx5_cmd_cleanup(dev); return 0; } +static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot) +{ + int err; + + err = mlx5_function_enable(dev); + if (err) + return err; + + err = mlx5_function_open(dev, boot); + if (err) + mlx5_function_disable(dev); + return err; +} + +static void mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot) +{ + if (!mlx5_function_close(dev, boot)) + mlx5_function_disable(dev); +} + static int mlx5_load(struct mlx5_core_dev *dev) { int err; @@ -1290,7 +1321,7 @@ int mlx5_init_one(struct mlx5_core_dev *dev) err = mlx5_function_setup(dev, true); if (err) - goto err_function; + goto err_function_setup; err = mlx5_init_once(dev); if (err) { @@ -1324,7 +1355,7 @@ int mlx5_init_one(struct mlx5_core_dev *dev) mlx5_cleanup_once(dev); function_teardown: mlx5_function_teardown(dev, true); -err_function: +err_function_setup: dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; mutex_unlock(&dev->intf_state_mutex); return err; @@ -1366,7 +1397,7 @@ int mlx5_load_one(struct mlx5_core_dev *dev) err = mlx5_function_setup(dev, false); if (err) - goto err_function; + goto err_function_setup; err = mlx5_load(dev); if (err) @@ -1386,7 +1417,7 @@ int mlx5_load_one(struct mlx5_core_dev *dev) mlx5_unload(dev); err_load: mlx5_function_teardown(dev, false); -err_function: +err_function_setup: dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; out: mutex_unlock(&dev->intf_state_mutex); From patchwork Tue Feb 8 17:14:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12739025 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 CAB5FC433EF for ; Tue, 8 Feb 2022 17:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352315AbiBHRPA (ORCPT ); Tue, 8 Feb 2022 12:15:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352343AbiBHROx (ORCPT ); Tue, 8 Feb 2022 12:14:53 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2046.outbound.protection.outlook.com [40.107.102.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5310DC061579; Tue, 8 Feb 2022 09:14:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pxp0e5vS1vsiP7oFKu2iqrv56IUDs65yy1t0wf99XDcJwb6DpIWRx7kLB/Zyy6Bwm5156fE0sEcpKQatee/B02kZ3z1h06WHikXu+tmLTgYkxltEkR6SoVuNZ8VrmSlAnAhGNPhgbHoYUzWHYtgfvzqGOi3i2zCNISPL43EY7o7iK5dGYj/fAVjB6SUfwkjaN3+nXMU2pgl6MhjXj9uZq2U5dOq+sXLlMXWmebXKw7SHbrrhpkaD7sOvLB6dSAgd3j9EjZ+SVmhe22ZggxwsFxEgUO5aWxkpDC6vBOZ/F5ded8tdIjgR36HxqkzLbB6P5OL+IUcfADqTBnGNBx89AQ== 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=O9SpnAZFq6PFMtygOpdxQylPAuS6Us4gXIQSvjUc1O8=; b=bSlZntf/oKgcDs1Sb2wIptVU115ApzydQ39Umb0Z3z7s9BeeiY3pb84NGPIJOB3nuyrltpgtB3ENiHC1vMGwBX73hqnwv948fqforrcT1mLJd+qu5WCxtIuVB40hD4S7Su1L5uSBON0/CRMT4+j5NUXVMzJY/Fk2vdIhJnEs+m57s6eileH9qwiZFPeWm5cB619IjriW5zoqWSVLQ84yryLScZRBq1cB/CCFc+eYR3VPOTBa1Eh+szojb1aVf+qwsLf4MOboLVy4ypu++bvZgIzmRD483eskE6e7rxXRGgpAzypFRJR9mK7eY0Y61RFNl4vJH2brp6jmOjzw5uQ7Fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=O9SpnAZFq6PFMtygOpdxQylPAuS6Us4gXIQSvjUc1O8=; b=CXr7j8dSlY0KQm759pfXJEZTM0QeFR47aldsNj4BdJxtSX1l1Y3/efH7Uj5HalEaNdHNfrOAeAMJ/BkF0GVsymN4RGadmahJPuAbVhWjtHvDHhAZULw7OpOSePu0I/AZQPF0O+y6UHXURyltSIf+hxBfDAJf68NnQoDsrkLWkMZX21uuwdNtAUxiln/nu92521bWuU6UtPHyklRICMj2rFZHT0E9PvwA/QhaxVcTp439kCABBsJaAKlCuWFFEqwgakCkUDzxpxb9Gb+YNrHsQ/rwCOLeib21HSaFALlSJ2/NsXGEK92YFWEK+PX0yHVqjMBxicOIPjRwAkI1C7J2tw== Received: from MWHPR20CA0031.namprd20.prod.outlook.com (2603:10b6:300:ed::17) by BY5PR12MB3892.namprd12.prod.outlook.com (2603:10b6:a03:1a2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Tue, 8 Feb 2022 17:14:50 +0000 Received: from CO1NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:300:ed:cafe::8a) by MWHPR20CA0031.outlook.office365.com (2603:10b6:300:ed::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Tue, 8 Feb 2022 17:14:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT029.mail.protection.outlook.com (10.13.174.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Tue, 8 Feb 2022 17:14:49 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 8 Feb 2022 17:14:49 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 8 Feb 2022 09:14:48 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Tue, 8 Feb 2022 09:14:46 -0800 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski CC: Jiri Pirko , Saeed Mahameed , , , Shay Drory Subject: [PATCH net-next 2/4] net/mlx5: Delete redundant default assignment of runtime devlink params Date: Tue, 8 Feb 2022 19:14:04 +0200 Message-ID: <1644340446-125084-3-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1644340446-125084-1-git-send-email-moshe@nvidia.com> References: <1644340446-125084-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 288437a7-07ad-437f-f6ed-08d9eb2683a1 X-MS-TrafficTypeDiagnostic: BY5PR12MB3892:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: el4OoL32i6ASWx3UzdiGxSNdnw5Jm+xf43+Jx0EnMgs4/0Kj7MdM6WuRcJ5Pyp1x+oM6WTO0spsT2S5epXyxESfITB574GCM6azqBxsLNp1kREE12yuUwhpFPijjh+G0VbbvgthHhMUkqi4GDv9HXi+/1LKE8sYikKEeXooOAgtIbOkeXbDhseurlwbB+DveOPWx4roGajtP02nXLPsFJeYKKfzkQWH+obIGGOLaPPOAFus3IYcRlSGR2axqrPoKnPWqtSoWKDx0VKThLGNsEbSCRDdvzSC0qmyd72XGiTl8lOLsV1+v66P/WaUW/4YhBEDHthlAkOGdz4xMgv8WRTU198CH4dktEKl9lP+3k7QXkr5IAEL7p0KUequbnwrWI/hpmgNUw1FIpyBQH6IuETcJ0V/k8wdELcGQYR7f/PJB2JXna8seSBWowh6PeRLicxmiPXDqHuacnczPbb6MUtOI4anPOCyphBq5/v/UlhC2rhcmLLrcvEtbYsyNXuHiHoBGMP3yGiVWjLt9HY6tYiefL5y8eeml2v+Iko6P8JdnwR2dA03dSVbHAwPyRfypuVY1M1heG3uMmY47dW7zIiR0cq/k1269GqUIcnslVrSma6TAMAghqLZkNhxmAjRveBmOwEKvFlEruKEp/3Z0cy73Mp6eqK4LLchQWNasYon6+ZhACkdarbhUW/GYS5E11XWjNcNKk9jUzt0nVqsN8g== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(7696005)(86362001)(5660300002)(508600001)(6666004)(26005)(36860700001)(2906002)(47076005)(83380400001)(107886003)(2616005)(36756003)(186003)(110136005)(82310400004)(356005)(8676002)(8936002)(70206006)(70586007)(316002)(426003)(336012)(81166007)(54906003)(40460700003)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 17:14:49.8100 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 288437a7-07ad-437f-f6ed-08d9eb2683a1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3892 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory Runtime devlink params always read their values from the get() callbacks. Also, it is an error to set driverinit_value for params which don't support driverinit cmode. Delete such assignments. In addition, move the set of default matching mode inside eswitch code. Signed-off-by: Shay Drory Reviewed-by: Saeed Mahameed Reviewed-by: Moshe Shemesh --- .../net/ethernet/mellanox/mlx5/core/devlink.c | 20 ------------------- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 3 +++ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index d1093bb2d436..e832a3f4c18a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -588,14 +588,6 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink) struct mlx5_core_dev *dev = devlink_priv(devlink); union devlink_param_value value; - if (dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS) - strcpy(value.vstr, "dmfs"); - else - strcpy(value.vstr, "smfs"); - devlink_param_driverinit_value_set(devlink, - MLX5_DEVLINK_PARAM_ID_FLOW_STEERING_MODE, - value); - value.vbool = MLX5_CAP_GEN(dev, roce); devlink_param_driverinit_value_set(devlink, DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, @@ -606,18 +598,6 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink) devlink_param_driverinit_value_set(devlink, MLX5_DEVLINK_PARAM_ID_ESW_LARGE_GROUP_NUM, value); - - if (MLX5_ESWITCH_MANAGER(dev)) { - if (mlx5_esw_vport_match_metadata_supported(dev->priv.eswitch)) { - dev->priv.eswitch->flags |= MLX5_ESWITCH_VPORT_MATCH_METADATA; - value.vbool = true; - } else { - value.vbool = false; - } - devlink_param_driverinit_value_set(devlink, - MLX5_DEVLINK_PARAM_ID_ESW_PORT_METADATA, - value); - } #endif value.vu32 = MLX5_COMP_EQ_SIZE; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 458ec0bca1b8..25f2d2717aaa 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -1582,6 +1582,9 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC; else esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE; + if (MLX5_ESWITCH_MANAGER(dev) && + mlx5_esw_vport_match_metadata_supported(esw)) + esw->flags |= MLX5_ESWITCH_VPORT_MATCH_METADATA; dev->priv.eswitch = esw; BLOCKING_INIT_NOTIFIER_HEAD(&esw->n_head); From patchwork Tue Feb 8 17:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12739026 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 76923C433F5 for ; Tue, 8 Feb 2022 17:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352575AbiBHRPB (ORCPT ); Tue, 8 Feb 2022 12:15:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352438AbiBHROy (ORCPT ); Tue, 8 Feb 2022 12:14:54 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2055.outbound.protection.outlook.com [40.107.212.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A282C06157A; Tue, 8 Feb 2022 09:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BVsjtcaNSJawxz4CDbxtXmYelPVIWhBY/NfIOIihesAKlgDtwkF8bdHvGylgDGZU8kLuysw9kwmoibg++2ncRlVkwxI9fOtwB4jF4C0GeCzlkLuY4boagiXWq288N10JTCVOA/KHDEsmTzfrXjZpcO5M7KyWrsWpYFz1HHenDwsbHXDSDW9RuTbSG1YlTch5tq20hxr6Ao6M4V9LmS+q6xuZrZ7X0W0U1/zJOiuzUTd5qaGQKXTjAaJthiIkyOuqwQsvPwDIjwN42+a5XPlhaUJvl1QllHjpBD532xHCpZg7siQA9d6oA0Ljt2rCsIJGOKX2tZ5OV6tbuV8fhpEsQA== 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=bZnBWnw/+W2toaRTdq0SbAo6b96Qb16r+UMAcTqnt6M=; b=hTf1woH874s6YYu4dpzq8WtwNsbFP4ffdTQxpdhhgDefVj1h83kopzA0PuE3yOf70LdN6nbIyMjFH5E1RW/Xk+iTgxhwYuEzXNre+c1NzD6T5y++RN6EaNYqa1L/A3d7JGSeVpdSsOVgCJ9puWJO4EcZDn/UBB37b/w6qT1rTs+OClH6lU2AIMQka3y+TIQVijzKRPDEryuwztyxxl1ww7oQwwd8Q/dGyzUxezXc0Xxk+DGc1vBYriATnrFhTtMgemUzu3v9jxhh7553Gi1LrH7EeyPcn42jNfR9brup809IZCLO0l9y4iBhfnUGnd6VuAjGzznOfm2jC1XdG7gL6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=bZnBWnw/+W2toaRTdq0SbAo6b96Qb16r+UMAcTqnt6M=; b=cZCpsAUMQomi0j0Sx9YBOGZAaJi5Uan10xjBCX6VRpiPMk8tEpXQ4/LF+s1jr2A2+C4j3f38+Qwa/NkoLML86wj0gJCp5SjUmJFmSCBQpHeMdVBuUN4zwGVuU82KD5iKMKQB8fRsO9MsoSRCY/iJgTdC84AuEAnAWjIbpBvK0N6pEd+a6DpC1RbrQwny3IQToj2Id0iWEzt2qLHX9zxCrKd8AUEfSFn5YOxVZ4rJ0jCanHl+Z6qP8fAZq9RWzphh5wi6+yD/ERx1HP20M9e9kbbOKaiXOkYd7jb6kZCpxCOF7Lv9CtU64dRbBEzEZJDG9kFvtCSdYXYwdSYZg6m4Kw== Received: from MW4PR04CA0183.namprd04.prod.outlook.com (2603:10b6:303:86::8) by SA0PR12MB4352.namprd12.prod.outlook.com (2603:10b6:806:9c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Tue, 8 Feb 2022 17:14:52 +0000 Received: from CO1NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::b4) by MW4PR04CA0183.outlook.office365.com (2603:10b6:303:86::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14 via Frontend Transport; Tue, 8 Feb 2022 17:14:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT036.mail.protection.outlook.com (10.13.174.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Tue, 8 Feb 2022 17:14:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 8 Feb 2022 17:14:51 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 8 Feb 2022 09:14:51 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Tue, 8 Feb 2022 09:14:49 -0800 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski CC: Jiri Pirko , Saeed Mahameed , , , Shay Drory Subject: [PATCH net-next 3/4] devlink: Add new "enable_sfs_aux_devs" generic device param Date: Tue, 8 Feb 2022 19:14:05 +0200 Message-ID: <1644340446-125084-4-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1644340446-125084-1-git-send-email-moshe@nvidia.com> References: <1644340446-125084-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bbf6fc51-be9a-46d0-eb42-08d9eb268516 X-MS-TrafficTypeDiagnostic: SA0PR12MB4352:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eJd3sZZNwp+xU/0v7Jl9LgM+mrlTubEVP9tmpAxq/XyCCRa0ElI0MG6SBEHGWxR9/NVfKSJbeRmQgZkX+hPrnsnMGrUgpt+YatVjKbaL07s+ewUWRJ6CZT5eTWc0SYnm8lH5PHmozGtCIOHk4lGhOE86PbvKDFfWX4sKwJIDcpvrTsL2cp8f5jMFta63Cncu0eyLlkjv2vrddgzMWBmMNWzu2NoHmps0LwF9421SWUCQfW77IywIiXk0mDUnltiXS7LTCGOUVwDnj5mCSwrNH7Zu2/FOcaqY4SpixzSe4OTIc0BLaN9Gf2RYP3ZPA36Q5fQPC4GstSaRceM9gsMkNf9qlbMZGKK3znStGgy2Erg33H4ojBrwyPqejgL/VusC3LjPJSvFyVmhzGt/UPDFRvaWCWhHgNcUYxVCWGNsdqbBtXFBquoua2z+2I2rtACqydlZ+kxjcuYO//VLEcqXlqL+0jeCyfbUymSm/Vr/kyu7fvDIPQ5t7DhltnVmYnFXQForVeGI/aU9VaHZ3C8BX+MTHfybIvcAz9mpn/a5rlXzPZ8i0UiWznrWaHCjJqAvmb5vnSdO2o/AegboeZm1GrYlpTVgqdBajYR9SQE3TDIrpMX/hiSxvXoLlfILfq1GhK4fYcpc0/P1LVI59nGC87ODg1Gw+BqJoqa2OdPLmEVMjwzLPUWRPzHKcsJT3m6t1HwUYM8gVmesPWv3GkX74MsI6SotW/xz9jvv7eG3CCc= X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(8676002)(8936002)(336012)(186003)(82310400004)(47076005)(107886003)(83380400001)(426003)(26005)(6666004)(4326008)(110136005)(54906003)(70586007)(70206006)(36756003)(5660300002)(316002)(40460700003)(7696005)(81166007)(36860700001)(508600001)(356005)(2906002)(2616005)(86362001)(41533002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 17:14:52.2542 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbf6fc51-be9a-46d0-eb42-08d9eb268516 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4352 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory Add new device generic parameter to enable/disable creation of Sub-Functions auxiliary devices of a certain Physical-Function. User who wants to use specific SFs auxiliary devices, can disable the creation of all SF auxiliary devices upon SF creation. After the SF is created, the user can enable only the requested auxiliary devices. for example: $ devlink dev param set pci/0000:08:00.0 \ name enable_sfs_aux_devs value false cmode driverinit Create SF: $ devlink port add pci/0000:08:00.0 flavour pcisf pfnum 0 sfnum 11 $ devlink port function set pci/0000:08:00.0/32768 \ hw_addr 00:00:00:00:00:11 state active Enable ETH auxiliary device: $ devlink dev param set auxiliary/mlx5_core.sf.1 \ name enable_eth value true cmode driverinit $ devlink dev reload auxiliary/mlx5_core.sf.1 At this point the user have SF devlink instance with auxiliary device for the Ethernet functionality only. Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko Reviewed-by: Moshe Shemesh --- Documentation/networking/devlink/devlink-params.rst | 5 +++++ include/net/devlink.h | 4 ++++ net/core/devlink.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst index 4e01dc32bc08..aa0edb915f88 100644 --- a/Documentation/networking/devlink/devlink-params.rst +++ b/Documentation/networking/devlink/devlink-params.rst @@ -137,3 +137,8 @@ own name. * - ``event_eq_size`` - u32 - Control the size of asynchronous control events EQ. + * - ``enable_sfs_aux_devs`` + - Boolean + - When enabled, the device driver will instantiate all auxiliary devices of + SFs of the devlink device. When clear, the SFs of the devlink device will + not instantiate any auxiliary devices. diff --git a/include/net/devlink.h b/include/net/devlink.h index 8d5349d2fb68..8013252790bf 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -461,6 +461,7 @@ enum devlink_param_generic_id { DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP, DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE, DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE, + DEVLINK_PARAM_GENERIC_ID_ENABLE_SFS_AUX_DEVS, /* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX, @@ -519,6 +520,9 @@ enum devlink_param_generic_id { #define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME "event_eq_size" #define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE DEVLINK_PARAM_TYPE_U32 +#define DEVLINK_PARAM_GENERIC_ENABLE_SFS_AUX_DEVS_NAME "enable_sfs_aux_devs" +#define DEVLINK_PARAM_GENERIC_ENABLE_SFS_AUX_DEVS_TYPE DEVLINK_PARAM_TYPE_BOOL + #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ diff --git a/net/core/devlink.c b/net/core/devlink.c index fcd9f6d85cf1..b5368024ac18 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4477,6 +4477,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME, .type = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE, }, + { + .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_SFS_AUX_DEVS, + .name = DEVLINK_PARAM_GENERIC_ENABLE_SFS_AUX_DEVS_NAME, + .type = DEVLINK_PARAM_GENERIC_ENABLE_SFS_AUX_DEVS_TYPE, + }, }; static int devlink_param_generic_verify(const struct devlink_param *param) From patchwork Tue Feb 8 17:14:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12739028 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 CD12CC433F5 for ; Tue, 8 Feb 2022 17:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383392AbiBHRPZ (ORCPT ); Tue, 8 Feb 2022 12:15:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352564AbiBHRPP (ORCPT ); Tue, 8 Feb 2022 12:15:15 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2077.outbound.protection.outlook.com [40.107.236.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B341BC0613CC; Tue, 8 Feb 2022 09:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U9RIYlVNHB71/KIw07tdPSngmUAE7dywMgRpvedT4/piYIApWMyzZhvGan3reKNWG8tSyySxmerN3jMnqrSch+CsaqCfskENCPHkgV+DJC+zBoraHJC7NR3FEXRS0d6h51HkXP2mKQhE6NbjHSmNzN9giHNMuFFvVrw8UIlmwRUfMpA0yhyGYca0rV3ivnRWHa0xm6tWesyyuz/+O4HZG7u8SSx6fteBIERKReshTT9+GdUq+SDcy0SytDUGPL5igM0UVqwuBSkEgVXrYdgmuuThTZJLtNVo6ry7nIs7wAB946djD5q3SfZiEd72uAcujl+5k7VGG4TusoT7NvQT1w== 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=zq9Nr4bC0VlgPmFexyOAJe9CTrvgvKV0U8fbewUwnps=; b=gjy7kyv8DCESzYQZM5WZCtOlevqBErsPeQ9JSvPUorxomuL8ULDKv1lyIm9JxEKS663/PiIuyUr6xK0Q8r+4jllpZLgaAGzEdR/ORoiR/d84FqvCz9TqGX08LGJdGECiRD3H8/X8SdELq9/DY1+cwhKYf3GPgnxVvQ3yp1GOplIMjuZeYj4BsDYYA2xkl+MfrPjzzURVJGsxzyFLnSwCiVaHSqbqaYdIS3Ez1sTGPyOL0QXqFLvfKNMq0o6DBmjTZQBSnqZZAecnwITG0E6ieTLA/2rKC2E5Cmx47xpJQTQ7bCL952dw/dTPuEe0GyWqzs6WNK9qsEnCN781hTRmlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=zq9Nr4bC0VlgPmFexyOAJe9CTrvgvKV0U8fbewUwnps=; b=P66IPRVWRGWnfMWQUM8h/H5zLt2uJUkwtv+dovXjulOOo0z5/pOBdApJPy0tLQ5Yb3BD5+QHVodybpNcwF/DvED8BzQiUJU5Y6AoNNJUzigzDHZWPaO7ASDkWvB7NZ7Zd7ulK0vRsUQHnOKHauPBC0rtT1EGqyVSuJPOeHD35b1PmQOqh0X3E4xjjvp7y26thqDSvX5S82KmgWfGFQZxrFCE9roErKeQQ0ispdmFQ20VL8GfT/QEl8EaJ8Vyu6EwJDFabB8G5PQosJ4n8m6Fa0DXjOG/ewDvXlGCGa4zO/LTvaDUjcqcej8mdG4s488Na5WxFkAdyv8wlVZQU/Ys7w== Received: from DM3PR11CA0019.namprd11.prod.outlook.com (2603:10b6:0:54::29) by SA0PR12MB4446.namprd12.prod.outlook.com (2603:10b6:806:71::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Tue, 8 Feb 2022 17:15:08 +0000 Received: from DM6NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:0:54:cafe::a1) by DM3PR11CA0019.outlook.office365.com (2603:10b6:0:54::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Tue, 8 Feb 2022 17:15:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT048.mail.protection.outlook.com (10.13.173.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Tue, 8 Feb 2022 17:15:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 8 Feb 2022 17:14:54 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 8 Feb 2022 09:14:53 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Tue, 8 Feb 2022 09:14:51 -0800 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski CC: Jiri Pirko , Saeed Mahameed , , , Shay Drory Subject: [PATCH net-next 4/4] net/mlx5: Support enable_sfs_aux_devs devlink param Date: Tue, 8 Feb 2022 19:14:06 +0200 Message-ID: <1644340446-125084-5-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1644340446-125084-1-git-send-email-moshe@nvidia.com> References: <1644340446-125084-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65f917f2-83e1-4494-7b98-08d9eb268ec8 X-MS-TrafficTypeDiagnostic: SA0PR12MB4446: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: ChC5Vp3OfZ2ceP5Afctcea9IDe5Ij6i3mZrzGV6vOMyo6RQQ+dznOc0c+MDOMp17cWXkzqGdBRvYECwQe3bdmJ1enSG0X/E6qjiv1ak6zT1ZVTMS5lDmH7QYugMOvadelzsRyTDTlS5cLrwQ4SvaiWosCLhNtJdrbEL//cT+C3XGkI10r46HKV9X5BkaCw2MIv9zASVPAxpEk7XwuN7yEIObBxdoFm21b1iE6y4IIk2HtYxcDvAd1lMj3oDcYulQDYZBNeIN0XYWQawMOeXIvJYWgyR2o+xqdEGU2ufd1O6PRStFC2RfPKWRLDE27Brk/q97md/ZFr47bFNGbr/7G7Lzb7MhocLkjoQe0YspvjTKh0mYmo1NPf5nTY04C+b9+ZFJVRjFu+dqFHvNUMwBsSDvdmRjAz4Gy3lDIGC6nGJvQ20nzSfn/8BNCqB/h42qkYgpquSGqgdN/0lClliYfQDZewo3PT8darjZgfJMDluA029ZnVtnQFCV0QvKb+rEKSOhVYduECqxZOwqmEQcunRXPCpVioSDoDgRM0f+yJj4EOl6FLrO9aS8QJd4jG42QybQozgb3HgGT2mO+RsoE61S5Nnzu8l63lzA0COfnUyRSZyEqcn9zBSS5tug2UfcSW4VAFCxfMf/CZNyPXJ/xZ+kRGUoQOHw9bhSOHasDfuTJWqi6L0uS7ObL67DgEG3Y4a3hju66a+4tlykjErk7UaCgKiyjFfPk/1IbTUJqeI= X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(54906003)(110136005)(356005)(70206006)(70586007)(81166007)(6666004)(8936002)(4326008)(8676002)(83380400001)(86362001)(7696005)(36860700001)(426003)(336012)(40460700003)(2616005)(5660300002)(2906002)(30864003)(26005)(186003)(316002)(47076005)(107886003)(82310400004)(36756003)(508600001)(21314003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 17:15:08.5017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65f917f2-83e1-4494-7b98-08d9eb268ec8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4446 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory In case user wants to configure the SFs, for example: to use only vdpa functionality, he needs to fully probe a SF, configure what he wants, and afterward reload the SF. In order to save the time of the reload, exposing a devlink runtime param on the PF, that when set to off, the SFs won't create any auxiliary sub-device, so that the SF can be configured prior to its full probe. Usage example: $ devlink dev param set pci/0000:00:0b.0 name enable_sfs_aux_devs \ value false cmode runtime Create SF: $ devlink port add pci/0000:08:00.0 flavour pcisf pfnum 0 sfnum 11 $ devlink port function set pci/0000:08:00.0/32768 \ hw_addr 00:00:00:00:00:11 state active Enable ETH auxiliary device: $ devlink dev param set auxiliary/mlx5_core.sf.1 \ name enable_eth value true cmode driverinit Now, in order to fully probe the SF, use devlink reload: $ devlink dev reload auxiliary/mlx5_core.sf.1 At this point the user have SF devlink instance with auxiliary device for the Ethernet functionality only. Signed-off-by: Shay Drory Reviewed-by: Moshe Shemesh --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 16 +++ .../net/ethernet/mellanox/mlx5/core/devlink.c | 31 +++++- .../net/ethernet/mellanox/mlx5/core/health.c | 5 +- .../net/ethernet/mellanox/mlx5/core/main.c | 102 +++++++++++++++++- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 6 ++ .../mellanox/mlx5/core/sf/dev/driver.c | 13 ++- .../ethernet/mellanox/mlx5/core/sf/devlink.c | 40 +++++++ .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 7 ++ .../net/ethernet/mellanox/mlx5/core/sf/priv.h | 2 + include/linux/mlx5/driver.h | 1 + 10 files changed, 211 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index ba6dad97e308..89ead37b98ad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -333,6 +333,18 @@ static void del_adev(struct auxiliary_device *adev) auxiliary_device_uninit(adev); } +void mlx5_dev_mark_unregistered(struct mlx5_core_dev *dev) +{ + mutex_lock(&mlx5_intf_mutex); + dev->priv.flags |= MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV; + mutex_unlock(&mlx5_intf_mutex); +} + +bool mlx5_dev_is_unregistered(struct mlx5_core_dev *dev) +{ + return dev->priv.flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV; +} + int mlx5_attach_device(struct mlx5_core_dev *dev) { struct mlx5_priv *priv = &dev->priv; @@ -473,6 +485,10 @@ static int add_drivers(struct mlx5_core_dev *dev) if (!is_supported) continue; + if (mlx5_adev_devices[i].is_enabled && + !(mlx5_adev_devices[i].is_enabled(dev))) + continue; + priv->adev[i] = add_adev(dev, i); if (IS_ERR(priv->adev[i])) { mlx5_core_warn(dev, "Device[%d] (%s) failed to load\n", diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index e832a3f4c18a..1b769b5da577 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -139,6 +139,13 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, struct pci_dev *pdev = dev->pdev; bool sf_dev_allocated; + if (mlx5_dev_is_unregistered(dev)) { + if (action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT) + return -EOPNOTSUPP; + mlx5_unload_one_light(dev); + return 0; + } + sf_dev_allocated = mlx5_sf_dev_allocated(dev); if (sf_dev_allocated) { /* Reload results in deleting SF device which further results in @@ -182,6 +189,10 @@ static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_a *actions_performed = BIT(action); switch (action) { case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: + if (mlx5_dev_is_unregistered(dev)) { + mlx5_fw_reporters_create(dev); + return mlx5_init_one(dev); + } return mlx5_load_one(dev); case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: if (limit == DEVLINK_RELOAD_LIMIT_NO_RESET) @@ -258,6 +269,9 @@ static int mlx5_devlink_trap_action_set(struct devlink *devlink, struct mlx5_devlink_trap *dl_trap; int err = 0; + if (mlx5_dev_is_unregistered(dev)) + return -EOPNOTSUPP; + if (is_mdev_switchdev_mode(dev)) { NL_SET_ERR_MSG_MOD(extack, "Devlink traps can't be set in switchdev mode"); return -EOPNOTSUPP; @@ -440,6 +454,9 @@ static int mlx5_devlink_fs_mode_get(struct devlink *devlink, u32 id, { struct mlx5_core_dev *dev = devlink_priv(devlink); + if (mlx5_dev_is_unregistered(dev)) + return -EOPNOTSUPP; + if (dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS) strcpy(ctx->val.vstr, "smfs"); else @@ -499,6 +516,9 @@ static int mlx5_devlink_esw_port_metadata_get(struct devlink *devlink, u32 id, { struct mlx5_core_dev *dev = devlink_priv(devlink); + if (mlx5_dev_is_unregistered(dev)) + return -EOPNOTSUPP; + if (!MLX5_ESWITCH_MANAGER(dev)) return -EOPNOTSUPP; @@ -542,6 +562,9 @@ static int mlx5_devlink_enable_remote_dev_reset_get(struct devlink *devlink, u32 { struct mlx5_core_dev *dev = devlink_priv(devlink); + if (mlx5_dev_is_unregistered(dev)) + return -EOPNOTSUPP; + ctx->val.vbool = mlx5_fw_reset_enable_remote_dev_reset_get(dev); return 0; } @@ -588,7 +611,7 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink) struct mlx5_core_dev *dev = devlink_priv(devlink); union devlink_param_value value; - value.vbool = MLX5_CAP_GEN(dev, roce); + value.vbool = MLX5_CAP_GEN(dev, roce) && !mlx5_dev_is_unregistered(dev); devlink_param_driverinit_value_set(devlink, DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, value); @@ -628,7 +651,7 @@ static int mlx5_devlink_eth_param_register(struct devlink *devlink) if (err) return err; - value.vbool = true; + value.vbool = !mlx5_dev_is_unregistered(dev); devlink_param_driverinit_value_set(devlink, DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, value); @@ -673,7 +696,7 @@ static int mlx5_devlink_rdma_param_register(struct devlink *devlink) if (err) return err; - value.vbool = true; + value.vbool = !mlx5_dev_is_unregistered(devlink_priv(devlink)); devlink_param_driverinit_value_set(devlink, DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA, value); @@ -705,7 +728,7 @@ static int mlx5_devlink_vnet_param_register(struct devlink *devlink) if (err) return err; - value.vbool = true; + value.vbool = !mlx5_dev_is_unregistered(dev); devlink_param_driverinit_value_set(devlink, DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET, value); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 737df402c927..1b40ada0e9c2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -700,7 +700,7 @@ static const struct devlink_health_reporter_ops mlx5_fw_fatal_reporter_ops = { }; #define MLX5_REPORTER_FW_GRACEFUL_PERIOD 1200000 -static void mlx5_fw_reporters_create(struct mlx5_core_dev *dev) +void mlx5_fw_reporters_create(struct mlx5_core_dev *dev) { struct mlx5_core_health *health = &dev->priv.health; struct devlink *devlink = priv_to_devlink(dev); @@ -893,7 +893,8 @@ int mlx5_health_init(struct mlx5_core_dev *dev) struct mlx5_core_health *health; char *name; - mlx5_fw_reporters_create(dev); + if (!mlx5_dev_is_unregistered(dev)) + mlx5_fw_reporters_create(dev); health = &dev->priv.health; name = kmalloc(64, GFP_KERNEL); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 73d2cec01ead..b5e40ad0b5fb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1314,6 +1314,7 @@ static void mlx5_unload(struct mlx5_core_dev *dev) int mlx5_init_one(struct mlx5_core_dev *dev) { + bool light_probe = mlx5_dev_is_unregistered(dev); int err = 0; mutex_lock(&dev->intf_state_mutex); @@ -1335,9 +1336,14 @@ int mlx5_init_one(struct mlx5_core_dev *dev) set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state); - err = mlx5_devlink_register(priv_to_devlink(dev)); - if (err) - goto err_devlink_reg; + /* In case of light_probe, mlx5_devlink is already registered. + * Hence, don't register devlink again. + */ + if (!light_probe) { + err = mlx5_devlink_register(priv_to_devlink(dev)); + if (err) + goto err_devlink_reg; + } err = mlx5_register_device(dev); if (err) @@ -1347,7 +1353,8 @@ int mlx5_init_one(struct mlx5_core_dev *dev) return 0; err_register: - mlx5_devlink_unregister(priv_to_devlink(dev)); + if (!light_probe) + mlx5_devlink_unregister(priv_to_devlink(dev)); err_devlink_reg: clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state); mlx5_unload(dev); @@ -1443,6 +1450,93 @@ void mlx5_unload_one(struct mlx5_core_dev *dev) mutex_unlock(&dev->intf_state_mutex); } +/* In case of light probe, we don't need a full query of hca_caps, but only the bellow caps. + * A full query of hca_caps will be done when the device will reload. + */ +static int mlx5_query_hca_caps_light(struct mlx5_core_dev *dev) +{ + int err; + + err = mlx5_core_get_caps(dev, MLX5_CAP_GENERAL); + if (err) + return err; + + if (MLX5_CAP_GEN(dev, eth_net_offloads)) { + err = mlx5_core_get_caps(dev, MLX5_CAP_ETHERNET_OFFLOADS); + if (err) + return err; + } + + if (MLX5_CAP_GEN(dev, nic_flow_table) || + MLX5_CAP_GEN(dev, ipoib_enhanced_offloads)) { + err = mlx5_core_get_caps(dev, MLX5_CAP_FLOW_TABLE); + if (err) + return err; + } + + if (MLX5_CAP_GEN_64(dev, general_obj_types) & + MLX5_GENERAL_OBJ_TYPES_CAP_VIRTIO_NET_Q) { + err = mlx5_core_get_caps(dev, MLX5_CAP_VDPA_EMULATION); + if (err) + return err; + } + + return 0; +} + +int mlx5_init_one_light(struct mlx5_core_dev *dev) +{ + int err; + + dev->state = MLX5_DEVICE_STATE_UP; + err = mlx5_function_enable(dev); + if (err) { + mlx5_core_warn(dev, "mlx5_function_enable err=%d\n", err); + goto out; + } + + err = mlx5_query_hca_caps_light(dev); + if (err) { + mlx5_core_warn(dev, "mlx5_query_hca_caps_light err=%d\n", err); + goto query_hca_caps_err; + } + + err = mlx5_devlink_register(priv_to_devlink(dev)); + if (err) { + mlx5_core_warn(dev, "mlx5_devlink_reg err = %d\n", err); + goto query_hca_caps_err; + } + + return 0; + +query_hca_caps_err: + mlx5_function_disable(dev); +out: + dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; + return err; +} + +void mlx5_uninit_one_light(struct mlx5_core_dev *dev) +{ + mlx5_devlink_unregister(priv_to_devlink(dev)); + if (dev->state != MLX5_DEVICE_STATE_UP) + return; + mlx5_function_disable(dev); +} + +/* xxx_ligth() function are used in order to configure the device without full + * init (light init). e.g.: There isn't a point in reload a device to light state. + * Hence, mlx5_load_one_light() isn't needed. + */ + +void mlx5_unload_one_light(struct mlx5_core_dev *dev) +{ + if (dev->state != MLX5_DEVICE_STATE_UP) + return; + mlx5_function_disable(dev); + dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; +} + static const int types[] = { MLX5_CAP_GENERAL, MLX5_CAP_GENERAL_2, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index 6f8baa0f2a73..e2d827474552 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -209,11 +209,14 @@ int mlx5_attach_device(struct mlx5_core_dev *dev); void mlx5_detach_device(struct mlx5_core_dev *dev); int mlx5_register_device(struct mlx5_core_dev *dev); void mlx5_unregister_device(struct mlx5_core_dev *dev); +void mlx5_dev_mark_unregistered(struct mlx5_core_dev *dev); +bool mlx5_dev_is_unregistered(struct mlx5_core_dev *dev); struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev); void mlx5_dev_list_lock(void); void mlx5_dev_list_unlock(void); int mlx5_dev_list_trylock(void); +void mlx5_fw_reporters_create(struct mlx5_core_dev *dev); int mlx5_query_mtpps(struct mlx5_core_dev *dev, u32 *mtpps, u32 mtpps_size); int mlx5_set_mtpps(struct mlx5_core_dev *mdev, u32 *mtpps, u32 mtpps_size); int mlx5_query_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 *arm, u8 *mode); @@ -291,6 +294,9 @@ int mlx5_init_one(struct mlx5_core_dev *dev); void mlx5_uninit_one(struct mlx5_core_dev *dev); void mlx5_unload_one(struct mlx5_core_dev *dev); int mlx5_load_one(struct mlx5_core_dev *dev); +int mlx5_init_one_light(struct mlx5_core_dev *dev); +void mlx5_uninit_one_light(struct mlx5_core_dev *dev); +void mlx5_unload_one_light(struct mlx5_core_dev *dev); int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c index 7b4783ce213e..8d6e0e44e614 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c @@ -28,6 +28,9 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxilia mdev->priv.adev_idx = adev->id; sf_dev->mdev = mdev; + if (sf_dev->parent_mdev->priv.sfs_light_probe) + mlx5_dev_mark_unregistered(mdev); + err = mlx5_mdev_init(mdev, MLX5_DEFAULT_PROF); if (err) { mlx5_core_warn(mdev, "mlx5_mdev_init on err=%d\n", err); @@ -41,7 +44,10 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxilia goto remap_err; } - err = mlx5_init_one(mdev); + if (sf_dev->parent_mdev->priv.sfs_light_probe) + err = mlx5_init_one_light(mdev); + else + err = mlx5_init_one(mdev); if (err) { mlx5_core_warn(mdev, "mlx5_init_one err=%d\n", err); goto init_one_err; @@ -64,7 +70,10 @@ static void mlx5_sf_dev_remove(struct auxiliary_device *adev) struct devlink *devlink = priv_to_devlink(sf_dev->mdev); devlink_unregister(devlink); - mlx5_uninit_one(sf_dev->mdev); + if (mlx5_dev_is_unregistered(sf_dev->mdev)) + mlx5_uninit_one_light(sf_dev->mdev); + else + mlx5_uninit_one(sf_dev->mdev); iounmap(sf_dev->mdev->iseg); mlx5_mdev_uninit(sf_dev->mdev); mlx5_devlink_free(devlink); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c index 3be659cd91f1..e3f6066ab7af 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c @@ -10,6 +10,7 @@ #include "ecpf.h" #define CREATE_TRACE_POINTS #include "diag/sf_tracepoint.h" +#include "devlink.h" struct mlx5_sf { struct devlink_port dl_port; @@ -456,6 +457,44 @@ static int mlx5_sf_vhca_event(struct notifier_block *nb, unsigned long opcode, v return 0; } +static int mlx5_devlink_sfs_light_probe_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + ctx->val.vbool = !dev->priv.sfs_light_probe; + return 0; +} + +static int mlx5_devlink_sfs_light_probe_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + dev->priv.sfs_light_probe = !ctx->val.vbool; + return 0; +} + +static const struct devlink_param sfs_light_probe_param = + DEVLINK_PARAM_GENERIC(ENABLE_SFS_AUX_DEVS, BIT(DEVLINK_PARAM_CMODE_RUNTIME), + mlx5_devlink_sfs_light_probe_get, + mlx5_devlink_sfs_light_probe_set, NULL); + +int mlx5_devlink_sfs_light_probe_param_register(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + if (!mlx5_core_is_pf(dev) || !mlx5_sf_max_functions(dev)) + return 0; + + return devlink_param_register(devlink, &sfs_light_probe_param); +} + +void mlx5_devlink_sfs_light_probe_param_unregister(struct devlink *devlink) +{ + devlink_param_unregister(devlink, &sfs_light_probe_param); +} + static void mlx5_sf_table_enable(struct mlx5_sf_table *table) { init_completion(&table->disable_complete); @@ -533,6 +572,7 @@ int mlx5_sf_table_init(struct mlx5_core_dev *dev) table->dev = dev; xa_init(&table->port_indices); dev->priv.sf_table = table; + dev->priv.sfs_light_probe = false; refcount_set(&table->refcount, 0); table->esw_nb.notifier_call = mlx5_sf_esw_event; err = mlx5_esw_event_notifier_register(dev->priv.eswitch, &table->esw_nb); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c index 17aa348989cb..664704598b76 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c @@ -283,9 +283,15 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev) if (err) goto ext_err; + err = mlx5_devlink_sfs_light_probe_param_register(priv_to_devlink(dev)); + if (err) + goto sfs_reg_err; + mlx5_core_dbg(dev, "SF HW table: max sfs = %d, ext sfs = %d\n", max_fn, max_ext_fn); return 0; +sfs_reg_err: + mlx5_sf_hw_table_hwc_cleanup(&table->hwc[MLX5_SF_HWC_EXTERNAL]); ext_err: mlx5_sf_hw_table_hwc_cleanup(&table->hwc[MLX5_SF_HWC_LOCAL]); table_err: @@ -301,6 +307,7 @@ void mlx5_sf_hw_table_cleanup(struct mlx5_core_dev *dev) if (!table) return; + mlx5_devlink_sfs_light_probe_param_unregister(priv_to_devlink(dev)); mutex_destroy(&table->table_lock); mlx5_sf_hw_table_hwc_cleanup(&table->hwc[MLX5_SF_HWC_EXTERNAL]); mlx5_sf_hw_table_hwc_cleanup(&table->hwc[MLX5_SF_HWC_LOCAL]); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h b/drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h index 7114f3fc335f..c228edc8e43c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h @@ -19,4 +19,6 @@ void mlx5_sf_hw_table_sf_free(struct mlx5_core_dev *dev, u32 controller, u16 id) void mlx5_sf_hw_table_sf_deferred_free(struct mlx5_core_dev *dev, u32 controller, u16 id); bool mlx5_sf_hw_table_supported(const struct mlx5_core_dev *dev); +int mlx5_devlink_sfs_light_probe_param_register(struct devlink *devlink); +void mlx5_devlink_sfs_light_probe_param_unregister(struct devlink *devlink); #endif diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 78655d8d13a7..fd07175896ff 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -604,6 +604,7 @@ struct mlx5_priv { struct mlx5_vhca_state_notifier *vhca_state_notifier; struct mlx5_sf_dev_table *sf_dev_table; struct mlx5_core_dev *parent_mdev; + u8 sfs_light_probe:1; #endif #ifdef CONFIG_MLX5_SF_MANAGER struct mlx5_sf_hw_table *sf_hw_table;