From patchwork Tue Apr 9 19:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623079 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2073.outbound.protection.outlook.com [40.107.101.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29D05157A4A for ; Tue, 9 Apr 2024 19:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689756; cv=fail; b=FC3ZYruqFe5iTtbxLZn+vFsgA2Y/ntQNS6TSvcSXFJpF8dc8ONjv7N5/YgnCFRE5tH57idaVyxeF9aJXcWasiqA+6VR3ur2iHpJoF8gbmrGX0iFs0ivtVrRWHBZATQQa8+5uEwyb9P4IW+n7fN6Vz1PxSfp1RUHppIk3hb8ot8Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689756; c=relaxed/simple; bh=LrLVdpif73/P9yECTZCyE1R3fjA0k5Kr7DKSM312ebQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KfsZeC/F+v1iPEQ4MPwh/EVmkEywzPkkuRn5fzmtjhgtXQ2hL7QZ5U+jBibZNefEpdcGt4OlfXajGAlbrg5T3VGx8PDpT9NDzwr0x/uFC37ZXBxquF1PhIk92yOWJSsNCe0ohw6p4HiYifXbUrgGEbQ0Dul0rESFjMJZA+qIpSA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=SEsEkRHz; arc=fail smtp.client-ip=40.107.101.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SEsEkRHz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mFmLt5CUHGVu79D3KCc5yxMHe9HCvaVYZP4lcSbDSp2cGiHstlFBqY8m249DWSeIet36703i3iidcGyBpfzWGmezm1ISjp7aiCWARgiDe/XZQIKVIgJ/Err4BjgblhW3Du2VzDPOhCRUPXkn5h2I9Ymoh1xgKPDlOz4RRLBt+p47GQeWyOGJrGb6QlDEB07Q04MwnYFYvJLpXtAzgjWk946ij8hQMLbZp8RKzx5PmyWnLMSOcyqKjtXJsXbKIpAg5vYgE+rqwpThX7ADlYNwmiqiJEskY/oC8pV5wJFFOmR5n1VybnKfjFG2aAKWPv8BilTTDlVDr0Ykq/jAOMH4hQ== 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=r2tU07MfajrKYL3NPKOFAwbXTNHEqvJ2RBi82n/ZbhA=; b=HbeBidR5l1Qsn43IJ7NVzD8xKXNBf9TIOH2GcbstqXxQPUW5HIMQHD9mZqYlXDiMitlE6b5G+4DgFanXD9Hy/+fq/V29P8UMJUi2rs0L3MjSwNKL8Pr/s/QzDI5uPAuDAS3dAU3wGdJ5u2v3AHyGJ/yyh0Fm0VXp5FwNpd/7mobSh80LIer0BmqQrceVBmo33jYpq1Rjw3qRdnvVM1eQZ9FNDLTEwkMhHzAL4lkbEWq2wAg4O7m84aMNXIkyOVqE1sUH/lu5h6uYZnEgRPcO41/yO2EY82d6c8TECxA0uyP1pwApBVsI/w4jCf+Ml4if6s2ydLZ+igsaq5GSSoal1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r2tU07MfajrKYL3NPKOFAwbXTNHEqvJ2RBi82n/ZbhA=; b=SEsEkRHzMYDU7U6r7KibCD1Lldsu6TLw/hxloY6ftbvPdUGMiY+WpJnSbzCmoTafJ01hBNhUkePvIi88PzhiC8pjh0XSF2u1PScHpsGMZwtLpMjQi8ePWzazgUMtNUOwiEz0ZFYPrBW2izM38pmDUXE68sNat6CRh/asVCo6TDo3I9myMsvL6P1FhCojTOcYnSEvxKBUFFOcXJTyB0l57nljWl4k4rO2GQ5ml9fOpAvgOG0/WzKMI0j8KxCvzcjShCzoXchMoxk57PCH7+6wb+a39EXcBlE/t7bJT9rLCcqD841/IPtGSpkNdOfvCxdq/6tJWYYYJRNPJF/6QkBfSg== Received: from CH0P221CA0048.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11d::29) by DS0PR12MB9448.namprd12.prod.outlook.com (2603:10b6:8:1bb::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:11 +0000 Received: from CH3PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:11d:cafe::26) by CH0P221CA0048.outlook.office365.com (2603:10b6:610:11d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH3PEPF00000017.mail.protection.outlook.com (10.167.244.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.0 via Frontend Transport; Tue, 9 Apr 2024 19:09:10 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:08:45 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:08:44 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:08:41 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Shay Drory , Moshe Shemesh , Tariq Toukan Subject: [PATCH net V2 01/12] net/mlx5: E-switch, store eswitch pointer before registering devlink_param Date: Tue, 9 Apr 2024 22:08:09 +0300 Message-ID: <20240409190820.227554-2-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000017:EE_|DS0PR12MB9448:EE_ X-MS-Office365-Filtering-Correlation-Id: ff0430a3-8796-4019-780f-08dc58c889d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YbELhrak/966ab9dZnN2mR0CdrD/S9kJrhpryMx96sTD/EybEjAg5M1IxwhdK+Y71RQ9IRPv7AHI93aGXDkS9ViaD+beb3WbGfL8MAUT3UuZjj2waNYAu2I8PmpE83aKDjkOMMwhXdFrKBzZCASco3PN95/nliNwuL/PjPz0VgnCO186hkDQUjY1FrHO9LrduE8rFvlrVPWdI5RiFQ27ZNsLwdB7vqe1j64LdV4RXJVmiTcHDMW3Hpp8HTofGfkNZeczF9GMEsBxNe8NK0apzr9C4Pd57q6p2Bp10hpEGxFyY/Cyh/ETiAcEnALlbPbv1ooIsH60MhaPwqsVFokd6PKq3odSUDJ1L4Ad+M3122taCKVPzVCU/vKsJa9wO8cGLPgx/8RFG8g9vN1l4sRGmP5pjHTJ0wsqe1ZwR7R7e/PAonenT4Mwq3VVDjWT5QKaqURb1s+hM9amsTGzrzqwt78CTkRvOvkAOiTI86m9VQj17vmqYACLV5vGSPvrKFYLTEqqZ3sFWiH5r3fymECgxX/mvT4cgd0O5I8GjdhJZWQ69+dtpg1q2XNLWENKok6qV9QDJ895rZsMm2iDhuRrWWbXkXl+iET4udZ0Xl7guqbf000yYK7XjwZcxcpD91TAsV/T0CeUuocMUuMxBCFCWN6RxahGkeogXGXbgeMo53AyyvpDgs1E0y+4kD4nm2MUlntrAGcNQsEtLCqh34/HWiwtip0arixt/H7hi8clDNQ= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:10.7377 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff0430a3-8796-4019-780f-08dc58c889d5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9448 X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory Next patch will move devlink register to be first. Therefore, whenever mlx5 will register a param, the user will be notified. In order to notify the user, devlink is using the get() callback of the param. Hence, resources that are being used by the get() callback must be set before the devlink param is registered. Therefore, store eswitch pointer inside mdev before registering the param. Signed-off-by: Shay Drory Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 9 +++------ .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 3047d7015c52..1789800faaeb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -1868,6 +1868,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) if (err) goto abort; + dev->priv.eswitch = esw; err = esw_offloads_init(esw); if (err) goto reps_err; @@ -1892,11 +1893,6 @@ 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); esw_info(dev, @@ -1908,6 +1904,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) reps_err: mlx5_esw_vports_cleanup(esw); + dev->priv.eswitch = NULL; abort: if (esw->work_queue) destroy_workqueue(esw->work_queue); @@ -1926,7 +1923,6 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) esw_info(esw->dev, "cleanup\n"); - esw->dev->priv.eswitch = NULL; destroy_workqueue(esw->work_queue); WARN_ON(refcount_read(&esw->qos.refcnt)); mutex_destroy(&esw->state_lock); @@ -1937,6 +1933,7 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) mutex_destroy(&esw->offloads.encap_tbl_lock); mutex_destroy(&esw->offloads.decap_tbl_lock); esw_offloads_cleanup(esw); + esw->dev->priv.eswitch = NULL; mlx5_esw_vports_cleanup(esw); debugfs_remove_recursive(esw->debugfs_root); devl_params_unregister(priv_to_devlink(esw->dev), mlx5_eswitch_params, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index baaae628b0a0..e3cce110e52f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -2476,6 +2476,10 @@ int esw_offloads_init(struct mlx5_eswitch *esw) if (err) return err; + if (MLX5_ESWITCH_MANAGER(esw->dev) && + mlx5_esw_vport_match_metadata_supported(esw)) + esw->flags |= MLX5_ESWITCH_VPORT_MATCH_METADATA; + err = devl_params_register(priv_to_devlink(esw->dev), esw_devlink_params, ARRAY_SIZE(esw_devlink_params)); From patchwork Tue Apr 9 19:08:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623084 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2066.outbound.protection.outlook.com [40.107.237.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 329C3158A18 for ; Tue, 9 Apr 2024 19:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689772; cv=fail; b=E9rh57mHcnWCsV/4V0Nwi3gbXJM/ize1bb5E/H3oHxQG5m/3MY3O6H01xZP6y8q4Uq160ZUQU3UjSOjq63C/ArfRRL3Yz6/DZNfyxoi1vg2Jm6Ngq1ZgDesbkM7L3EVtJUjTtyS2p3LBv0FYT9CG5jdTyfZMsjxSUsoVy3m/La4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689772; c=relaxed/simple; bh=yD/60l2sxO2zRiGX9Eb5hemtIhWVk7hHxZULiNonz+8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VW1ndrSlqo5unwnQZrsDwqFUveJ1AgjFl0diDhcYiuYqd1nhPjK9VKJWVVwdQjtMlbm1ed2Ufp96WEpPD1lmuNnIfQEZtxtJUc52yy+N0fg8orVN/55lzy8iwxpisRYs74xzyWNeiukw/p1DSNiyl9yhvgsh5DSSWQnpPQ4k6rU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=QkXS39fm; arc=fail smtp.client-ip=40.107.237.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="QkXS39fm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AkXlaz/YqjQcd7x5yVZZsnOZbcxycb6tUQqiybds+68mLYPFbJzT1jmFFsRfWhUpq4tIlnXyFeg8T3BMMYQkLfP9X67fKLTNuybsnX0DGhq0hcxp9G85ghNJ1gfJ+TEzb3zvUCrIziUnyinmh0nDjiRYc6W6C0eAGSZ8Bx46NhXWFjZauNiRZklKwA1/C/8YHVGrbFmqWrYKtQDBz/mQrZAESw/obBEEq124aagHg+G8nUBcV0IJkyolfjfEZNz1uZKqSX/and4NvJBJDxkwpA+UMQnIj5RP0BGacm7v8AMcJB/P4dNgkONWS/P7yLtVJ621grrKHwD40YDbQaaMbg== 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=Hi3gN/7ukdZFVklxHvVBKeQkDrRkrnm4RuDkohDYxX0=; b=gS6JvBkjceh63jowveb8rQyPLGr9r4FlnZFOB5WfP5tOYVlQZ9z0Ox/tFoJEQOQvknBxfs76QzalTJBzufKBwwTc2oEA9Gi/oAaqg8XFnQp4Lo/GXIqpwp7TXxIBagWOQujkMPIqVDulBi5DnWNPXYeq/1mYKP7+l5Y/0Eo+TfrvD6seXWx3vH45cwyBVm6V9e7gRFIFXkGoWLvQpQJ47Nck1Nr2zf50y4EWZwXjKMorUWRi7x+wwNU19ZECmhIPOkUiOBVORXhamHRQZ0fd2CVTIm3HpMcbLJwUiGRe2iWUiGyPrt6nHKK5xYIBYEbonKyX9Z9ZXKYK2d2aVElHZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hi3gN/7ukdZFVklxHvVBKeQkDrRkrnm4RuDkohDYxX0=; b=QkXS39fmGSrQAm5WhA3B4VmonS7E17qiXKahXmKYA0+emX/MM6qAkWNr/yGuT6+pzL4eHM9uy3sZTKpe38E1350uOQuI3/1skGlebDYH6R75kweKpnrZIXIL2o3aVSSxsQJJ/GFsJdQ+27UZnSDmRe3rDsH/sy/V20aa/hFhcgmpI4UNtjo2G2MOdscMMwxNgIpscIpT5XIAGp56mTzlcACVB6PNtx79LPghXZx2DP4JTPwAlce65XZ1h0FmgsHo1/h0kcLpJGDVicRcjLcQ8UDMTEj4IXswwQv8zMLPjwU9dqH5O6gMcgEhDbBh4DEtakU4hvkW6JziFh8oW5DrBA== Received: from BYAPR02CA0036.namprd02.prod.outlook.com (2603:10b6:a02:ee::49) by CH0PR12MB8550.namprd12.prod.outlook.com (2603:10b6:610:192::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:25 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:a02:ee:cafe::7f) by BYAPR02CA0036.outlook.office365.com (2603:10b6:a02:ee::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:20 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:08:48 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 9 Apr 2024 12:08:48 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:08:45 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Shay Drory , Moshe Shemesh , Tariq Toukan Subject: [PATCH net V2 02/12] net/mlx5: Register devlink first under devlink lock Date: Tue, 9 Apr 2024 22:08:10 +0300 Message-ID: <20240409190820.227554-3-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6731:EE_|CH0PR12MB8550:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c1ae08c-2c51-4f85-7ffd-08dc58c88f63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s9Jtoh03JODQcrMkR70WFaeHe0Xie1EucDWBal39/RNqlvJApFdJXBW/3ICkf63HzZY2DTmPMatW1sh0WUWcTUVF92ZFYd0fIRklKnWkIUd9VfVNKsjeMXZURxGgandv5KCl7LVfQsC74rDXxFTAQmsqyBGd4coqeb7k8QnqZrSTZcfeZmXh8ul+jPYhcJ30iUtK2EZsya408PmRbEei9iHGD07VsbJ4B7AgC3HAPS90aWtM7uAoEFIhX8VUZN31IR6DU4lhyvWcAvpqAn7jSPG69SzboMy56QtORcC80kCZaL8c77ywYJSpxjTnFx3c8mZRg3LKKmeM7R8v4/j7HdOxBMdZmS4G8Hy+NiRUYnB8S/44xhoGVbMgCpifYalijUNz5UMOqWKjMz0Y2tS1oEiNILSyX4oR/okGlhqUFS1arVjK7ANNZVexgMWX8XOyzkhrk9el2inGWQ+vHTZsaDDt2U/WvieY7/KxFjFVeM42xFk8dCiASoNduAm3uDEJLCQIfpf7FfW8roLv551TZhor7V7OJrUdgrCAn/v6SglCPqcRo5HoXJbmeQukP/6/YkFmhEUaJauGbhTm6fb3IE/Ryq/hjkP7niLRM3axvLX4A26rwH50vcTfZM2aY+poFHMW+JQZx4MGvHG+WG3ScbzD8N/bmB0IAA/kXy8Ir9t8y75E6qfBxJ9EH957UtTSpZIQcahhpOQjsp5Tmv5dPQB5j7x100sV8S/0EN6FuTIiUtGY8s2LABWEgjiuEwR9 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:20.0727 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c1ae08c-2c51-4f85-7ffd-08dc58c88f63 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8550 X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory In case device is having a non fatal FW error during probe, the driver will report the error to user via devlink. This will trigger a WARN_ON, since mlx5 is calling devlink_register() last. In order to avoid the WARN_ON[1], change mlx5 to invoke devl_register() first under devlink lock. [1] WARNING: CPU: 5 PID: 227 at net/devlink/health.c:483 devlink_recover_notify.constprop.0+0xb8/0xc0 CPU: 5 PID: 227 Comm: kworker/u16:3 Not tainted 6.4.0-rc5_for_upstream_min_debug_2023_06_12_12_38 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Workqueue: mlx5_health0000:08:00.0 mlx5_fw_reporter_err_work [mlx5_core] RIP: 0010:devlink_recover_notify.constprop.0+0xb8/0xc0 Call Trace: ? __warn+0x79/0x120 ? devlink_recover_notify.constprop.0+0xb8/0xc0 ? report_bug+0x17c/0x190 ? handle_bug+0x3c/0x60 ? exc_invalid_op+0x14/0x70 ? asm_exc_invalid_op+0x16/0x20 ? devlink_recover_notify.constprop.0+0xb8/0xc0 devlink_health_report+0x4a/0x1c0 mlx5_fw_reporter_err_work+0xa4/0xd0 [mlx5_core] process_one_work+0x1bb/0x3c0 ? process_one_work+0x3c0/0x3c0 worker_thread+0x4d/0x3c0 ? process_one_work+0x3c0/0x3c0 kthread+0xc6/0xf0 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 Fixes: cf530217408e ("devlink: Notify users when objects are accessible") Signed-off-by: Shay Drory Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/main.c | 37 ++++++++++--------- .../mellanox/mlx5/core/sf/dev/driver.c | 1 - 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index c2593625c09a..59806553889e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1480,6 +1480,14 @@ int mlx5_init_one_devl_locked(struct mlx5_core_dev *dev) if (err) goto err_register; + err = mlx5_crdump_enable(dev); + if (err) + mlx5_core_err(dev, "mlx5_crdump_enable failed with error code %d\n", err); + + err = mlx5_hwmon_dev_register(dev); + if (err) + mlx5_core_err(dev, "mlx5_hwmon_dev_register failed with error code %d\n", err); + mutex_unlock(&dev->intf_state_mutex); return 0; @@ -1505,7 +1513,10 @@ int mlx5_init_one(struct mlx5_core_dev *dev) int err; devl_lock(devlink); + devl_register(devlink); err = mlx5_init_one_devl_locked(dev); + if (err) + devl_unregister(devlink); devl_unlock(devlink); return err; } @@ -1517,6 +1528,8 @@ void mlx5_uninit_one(struct mlx5_core_dev *dev) devl_lock(devlink); mutex_lock(&dev->intf_state_mutex); + mlx5_hwmon_dev_unregister(dev); + mlx5_crdump_disable(dev); mlx5_unregister_device(dev); if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) { @@ -1534,6 +1547,7 @@ void mlx5_uninit_one(struct mlx5_core_dev *dev) mlx5_function_teardown(dev, true); out: mutex_unlock(&dev->intf_state_mutex); + devl_unregister(devlink); devl_unlock(devlink); } @@ -1680,16 +1694,20 @@ int mlx5_init_one_light(struct mlx5_core_dev *dev) } devl_lock(devlink); + devl_register(devlink); + err = mlx5_devlink_params_register(priv_to_devlink(dev)); - devl_unlock(devlink); if (err) { mlx5_core_warn(dev, "mlx5_devlink_param_reg err = %d\n", err); goto query_hca_caps_err; } + devl_unlock(devlink); return 0; query_hca_caps_err: + devl_unregister(devlink); + devl_unlock(devlink); mlx5_function_disable(dev, true); out: dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; @@ -1702,6 +1720,7 @@ void mlx5_uninit_one_light(struct mlx5_core_dev *dev) devl_lock(devlink); mlx5_devlink_params_unregister(priv_to_devlink(dev)); + devl_unregister(devlink); devl_unlock(devlink); if (dev->state != MLX5_DEVICE_STATE_UP) return; @@ -1943,16 +1962,7 @@ static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto err_init_one; } - err = mlx5_crdump_enable(dev); - if (err) - dev_err(&pdev->dev, "mlx5_crdump_enable failed with error code %d\n", err); - - err = mlx5_hwmon_dev_register(dev); - if (err) - mlx5_core_err(dev, "mlx5_hwmon_dev_register failed with error code %d\n", err); - pci_save_state(pdev); - devlink_register(devlink); return 0; err_init_one: @@ -1973,16 +1983,9 @@ static void remove_one(struct pci_dev *pdev) struct devlink *devlink = priv_to_devlink(dev); set_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state); - /* mlx5_drain_fw_reset() and mlx5_drain_health_wq() are using - * devlink notify APIs. - * Hence, we must drain them before unregistering the devlink. - */ mlx5_drain_fw_reset(dev); mlx5_drain_health_wq(dev); - devlink_unregister(devlink); mlx5_sriov_disable(pdev, false); - mlx5_hwmon_dev_unregister(dev); - mlx5_crdump_disable(dev); mlx5_uninit_one(dev); mlx5_pci_close(dev); mlx5_mdev_uninit(dev); 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 bc863e1f062e..e3bf8c7e4baa 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c @@ -101,7 +101,6 @@ static void mlx5_sf_dev_remove(struct auxiliary_device *adev) devlink = priv_to_devlink(mdev); set_bit(MLX5_BREAK_FW_WAIT, &mdev->intf_state); mlx5_drain_health_wq(mdev); - devlink_unregister(devlink); if (mlx5_dev_is_lightweight(mdev)) mlx5_uninit_one_light(mdev); else From patchwork Tue Apr 9 19:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623085 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79F26158A3B for ; Tue, 9 Apr 2024 19:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689774; cv=fail; b=O2JV2xX25kDtjkruROuc8Fe7fR4X96AQsqhmf1E5MVU70G8BbW8GtCgnCTSYaI70/E0zc4WhSj/yeFuvtieGwfmVqlLS8YVi1efavElRx+guHB5eYZ1PYZwCmTC1n5zwl0x5QPnrpIYc2n6K45fGb2ulp08fNn1rt1fIl0KO/QE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689774; c=relaxed/simple; bh=a+hcMiuzMiSz0tVSVz7teTtviG0x74OeCsBem+wFyhk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VxQya2eZZFIF7YUnWtMkibMh9sRZ0UBO2Qur5PyR2A/yzAaHwJLmklY+07mcwlQC+d59XCsjbXKhhcbTXgRC+erL7Nxf0R3oixf+orEW2jD4XauAToBmPlDWN4dHlIELHKk6ETGzd0DB4rYspSiKyt7z4/YCi7aKY3gcC3hszP4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=qi+vUQJo; arc=fail smtp.client-ip=40.107.220.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="qi+vUQJo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b1TPah+tUaBQoxgR+f6wienksrBIMpBqGbPiio8Hq5BLu1MVgW+S3WkCtuWyV1eEM8C3X7iivQik6eCRcw0KBtq27NSgqgXTRApZtqJA/QHY6FOAH683lItUo6QsgkAhW3UBS4yE87lEK0IVzT0mItA4Whxa2u7UAO4BlEMOR7kA5LQ8CjXevfhfZXctzeOKeiGH/PettlME/x6wbjC3H4KruEjMU+vDRkE6t9bHPsNTtO+YOnigbZybr8/cZuXWb/sspQn89T1vKdnSjSU2HOUIY/8WAk0nr9PqCxvVLOBbyLBO3y0+g//KQ88IKC22M0AOIfGDnJjCP6VPgES0vA== 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=oIiMFiEZmWJDusUAHVYej7E3nKB4qXBVdF5SYh2wTb0=; b=ASyMC1+I9HM9RjrikaFD/NMlBogAr+uSDK+3DBlZOgZVx0RyFbVt5qqAxOd2NB0nGr7TbcFyRBI0wjrqmr89fIv/xabkQxi+HlivM2U7RCL3QudrE3EBmZ6zA6T0nO9LYd+uljPsKmwjtkCHqQ82ZgYPW3CjeBarqDIDao5+5vdo5MH0KsYybgJVD0tR4D1GN3/g3CxVAXGakpdZU6Flc9jEODWPl6Y1srlRL/7eVb+tkTjR9q33pSvZcKnUNUaASrT1M7vmiK1cPs2lO7vLvSNDsmDMFeqqqST1Hx9fnUAlsKMR9MnW/+SW3S9nEO7yptFbjBQP+wzm0ADcrmxI+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oIiMFiEZmWJDusUAHVYej7E3nKB4qXBVdF5SYh2wTb0=; b=qi+vUQJo/3rBtLqbRI9vaOisicNN91iVMKbaMk0IbmmDYzP2s11JLHKpkOa47tYTSUjKZKKpOfdhUHyiMOyjtRMwHI3jRkoLC+5/dFpxVw6IqdKp52G9h16/WUqYVYfXxTHinMrKdeqWRT+gqcOyDmWpdrq/E1O99itNBwIgW3V1/2j0M6KmtVoyT24wO/ghH1sndJfXoWRfw5punKNgox02L9uVsiuekl7D+IAYYgzFx2KvOb1UQ5CUeBCl4Nk3OcNSTeDGtlADzEBlOwock9RkMTyFDLK6etqygvj1/NFW02pXj2F1wMKcJfuVhEl76FPHrUB82tu5vrqseJcUTg== Received: from MW4PR04CA0390.namprd04.prod.outlook.com (2603:10b6:303:81::35) by PH7PR12MB5656.namprd12.prod.outlook.com (2603:10b6:510:13b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.54; Tue, 9 Apr 2024 19:09:25 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:303:81:cafe::f6) by MW4PR04CA0390.outlook.office365.com (2603:10b6:303:81::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.35 via Frontend Transport; Tue, 9 Apr 2024 19:09:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:24 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:08:52 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:08:51 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:08:48 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Michael Liang , Mohamed Khalfella , Yuanyuan Zhong , Shay Drory , "Tariq Toukan" Subject: [PATCH net V2 03/12] net/mlx5: offset comp irq index in name by one Date: Tue, 9 Apr 2024 22:08:11 +0300 Message-ID: <20240409190820.227554-4-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|PH7PR12MB5656:EE_ X-MS-Office365-Filtering-Correlation-Id: c9dabc6f-4d4c-43ed-4e22-08dc58c89239 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d1tmdRidYinaHO4Pgb015PK1OVOqz8oXf2waPIsWkb4EcncA1xjURroEKIus1b3vuBt27lKVp6KkGSaL+tiMSgvOLvIl8c3lHrPNYCDDZAeXjG9Aq8khFgMZ4D+R+1e/ZPcULG+EY6GG9UTIHpk8SGWP8AWzyQ+UVvKsT+p3U0NoAwHtUE/Mvg2ViJiRfNGYuIpE4tyo6annYkiIOApgXwBm4Wgaiqx/S6hTHtKphur9ETg0KlvmFU5CUQ8DFYyyWCvF1u2DHEQEc4+v5vtEUWe5MSQq8a0gtfhjsu/ScmTJppMJbCwJzq9qCktRlJwhYibk2w2tdlZy7N/vNQ6eei22W+gzuuojTHFLtyew6xcZZ62uvB5WD2vT6r2Sk8TWfGNJ2GE0Nh42hoiQu3BOH0TFhLUXhTuFn/d5rBU0D+N2Hs8qLwlN7V2T+VZk6RDp0ngbGoA2VgNlCQlzrHCSB8SiKH2h2nikTYyMT6rNTrU0jDlnEjRD75USjInxXCq65SRD7TT9vkbzBnuArHGIyXHD5FyThBjTnC0cbElybFbsw27t0Y30gUg6dXnnDta1PesDokSBa3UxP1e0ZkrlAb0dVEbiCxS8R976e+CZDupyNPrG1Tw6HqD9iiShbvPHIVjNjIjdeAjasy0BcrvGUxikK4Pp/GnatrNTmrC1FB894q0zSWcxMOrXT7mDaE7OZOg5LX0ljoiY7HpT6OOHehnHhgJHb2p07o1at5p7B4Olu1NysL718f38XwsNYWNr X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(82310400014)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:24.8137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9dabc6f-4d4c-43ed-4e22-08dc58c89239 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5656 X-Patchwork-Delegate: kuba@kernel.org From: Michael Liang The mlx5 comp irq name scheme is changed a little bit between commit 3663ad34bc70 ("net/mlx5: Shift control IRQ to the last index") and commit 3354822cde5a ("net/mlx5: Use dynamic msix vectors allocation"). The index in the comp irq name used to start from 0 but now it starts from 1. There is nothing critical here, but it's harmless to change back to the old behavior, a.k.a starting from 0. Fixes: 3354822cde5a ("net/mlx5: Use dynamic msix vectors allocation") Reviewed-by: Mohamed Khalfella Reviewed-by: Yuanyuan Zhong Signed-off-by: Michael Liang Reviewed-by: Shay Drory Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c index 4dcf995cb1a2..6bac8ad70ba6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c @@ -19,6 +19,7 @@ #define MLX5_IRQ_CTRL_SF_MAX 8 /* min num of vectors for SFs to be enabled */ #define MLX5_IRQ_VEC_COMP_BASE_SF 2 +#define MLX5_IRQ_VEC_COMP_BASE 1 #define MLX5_EQ_SHARE_IRQ_MAX_COMP (8) #define MLX5_EQ_SHARE_IRQ_MAX_CTRL (UINT_MAX) @@ -246,6 +247,7 @@ static void irq_set_name(struct mlx5_irq_pool *pool, char *name, int vecidx) return; } + vecidx -= MLX5_IRQ_VEC_COMP_BASE; snprintf(name, MLX5_MAX_IRQ_NAME, "mlx5_comp%d", vecidx); } @@ -585,7 +587,7 @@ struct mlx5_irq *mlx5_irq_request_vector(struct mlx5_core_dev *dev, u16 cpu, struct mlx5_irq_table *table = mlx5_irq_table_get(dev); struct mlx5_irq_pool *pool = table->pcif_pool; struct irq_affinity_desc af_desc; - int offset = 1; + int offset = MLX5_IRQ_VEC_COMP_BASE; if (!pool->xa_num_irqs.max) offset = 0; From patchwork Tue Apr 9 19:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623081 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061.outbound.protection.outlook.com [40.107.94.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFDC1157A5D for ; Tue, 9 Apr 2024 19:09:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689764; cv=fail; b=Eyb2aOYE54Gb6HXN2CwBit9FO0wE0htnc5p6x+LS0mtu5m5YfizocNBZ5bXYb/E0YnMj0olCLVhtqRyxUNZQ++QGiQWEfBfhoOKi/8B8mhVY2TtN4S9G2tWq8iNVqEDdDvpsysQX4zVvOsWUf2xhH7RGkoUuQkYeuhRJLH4dEMY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689764; c=relaxed/simple; bh=/v5JlDkbKzZpQYBBah2ju3dJc0+cBFhGdCbVzrfEgXs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qHrNCpiFYOVVfSOk/RIwAwQI7kVt4C/ahC0aKuSwqOY4cIcWY6gn9sYWwN8yAD6RI9c9VPHmdJWqRhsiHEVW6yIQArY9tO7hUh8kgIOmwRq+4AHcPqx1/EwAElxRQEZKH4/vQZ0lX+iJUTYAhoainnXIAwkH7RtGISTxHRcqtTE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=sJbxA3QI; arc=fail smtp.client-ip=40.107.94.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="sJbxA3QI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=baMPv/i3bxHL/HeWZwE3lC0tEghWdu+4Es9Xe2yJO+MVm+6xwZlPrGaemn84B3wBelvOCMfzJuzuDUG2SKJY1T85IRzCYAq9kras9FXRiuF2qrbucbzHhX0Na0yXD2zPSiWTTuZ+j42P4DofsU1qWWxe7r9a799bVy0EzeUZ/EVag6x9l5r6+PEtrMn5YkBRYoVPfGOOy9zwLlhrYzM4Z+Vc7wh94rLjd3PiybCpmHyh/NfPP18u5IUOEkVq7CNfyM5YxTJeY81VrGBQwu8RE3fxGabxCVq54aOYGX5u4hmFfqvOZ9QnqH4+9WJYb5Y7Po61aZkH7Rerr9i+QtDp1Q== 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=y+/xu5NGzBnA2//hXU95MBjVfDa2Rwco1BeMV2CEHCA=; b=MV7reuMYY3JAgDUokBuwob1FIkCTMfd8XsJMY8YFyhJ3Kx7gn6V6OBvQUtllkeXBSq69iExmWjw4wB+fY9HRcuXq4GcNrpyGW8Kb1RK7tHioD4MhECMZnSXTHq29/ibQgrHdnhpN6qaUlVgv1PKep0AmDk2KklpOTfGpxKeHUuZrfI+liz9A9WYy31s/33cAlD03OSCwlUtN9WIXUw9wI9jk1lBb8rvN54ZOztUCtreBY2e+lDLx6CFIujULtQf789wuNmONjFyzRF7VGpGefBjoVs5GRPIo45Dk6eqdSJr5Jhd12OBPxCQ6C6dv26i2DvMh3DOYYFKmMSKK0mwwqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y+/xu5NGzBnA2//hXU95MBjVfDa2Rwco1BeMV2CEHCA=; b=sJbxA3QIUN9OtdPt6ZAlrzCCUtpHlGHw7oUBXpJ7tej7c032ltJdthk7vvmdZMQfeQATCn9jt6fAsleo3ZSO1KpTXh50ddmOVPqtGsnvJW3Jiae+jGf8h9e7oO4rjXpfTk4MecTZayKrpu+St48/oLy8YeNu3t1LpnRosownhWysOEJF9TSMOy7TWHeogJjxZPAOI0lKfNIuxhuyWt9wSscsx/VItaGQWkCBCMCIdRM8gncYMOjby2SHtVVle8+lcm0IinHWeEkUVab/ohDpAY192AMi3sPiursZwUwxEg3Bj40yBujjapbsVy5BHWRKRiTCrK6+Lcr0xbrBzkrT8A== Received: from DS7P222CA0017.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::26) by SA1PR12MB5659.namprd12.prod.outlook.com (2603:10b6:806:236::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:19 +0000 Received: from CH3PEPF00000014.namprd21.prod.outlook.com (2603:10b6:8:2e:cafe::88) by DS7P222CA0017.outlook.office365.com (2603:10b6:8:2e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Tue, 9 Apr 2024 19:09:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH3PEPF00000014.mail.protection.outlook.com (10.167.244.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.0 via Frontend Transport; Tue, 9 Apr 2024 19:09:18 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:08:55 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:08:55 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:08:52 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Cosmin Ratiu , Tariq Toukan , Mark Bloch Subject: [PATCH net V2 04/12] net/mlx5: Properly link new fs rules into the tree Date: Tue, 9 Apr 2024 22:08:12 +0300 Message-ID: <20240409190820.227554-5-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000014:EE_|SA1PR12MB5659:EE_ X-MS-Office365-Filtering-Correlation-Id: 527f3c45-d83e-4ef7-aba6-08dc58c88e7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2vsQ9siXsCZJ8qEHjMCRwMNrHlXq4myT8DVcUMXEU7OC4ogRHUU2N/aub0jS4sV2KKPEtFNkvabV91Im+P4wcxeBSJYQDsQzMAsRstgIw1wTGHRlF4JgCR30yJx7WXlHoG7AcoqpBZfE7BcmlRAc4DX8MBxWXhZNZ3gH/wqSYvqHJBTpEGrK6taFltCI5oUM7Hykzbs3QaPpvPf3KIaPeILqifjoJ7kXcK1pdQozdNkxFmkP44NGHVIGT7aJgfmQCPc1Klryb2S4jtu5CCgEbApxe+x4IaT+vBp0TX2OyjiZ9TgsRVDz1RwzmPs9aSX7VL2cKtWxI8CepJiUBOfGKqRKcFHAkfqlTz8+tMyfr39k0L58v2SUYAC2eTsfmqMkqvC1/5O1nRJJ5eYrqrRJI2AGry8zjds7SNRlXNXyzZ+7khSx1toV1IkUnghfKc6sIWYg5fh801dD+GHq4jO3u9kroSLTJImDaeL1yaySovpSCVwU+3ZfO1i3OqDKgFG4Iw+sfbeMsEK7bsFRrQiyNfNCunhs9XDQGY0KPBgaQrWUT48b3TL1D2t3c2IuIzPP1vX60rsvTxsP/NWm8Dtpvb+gAC6jvtgWkq7DJ3PtNuq8QOYHh4ODuYEeZF4yU3PLmvZBl/g1awMHEjLIPFoHNt1bdnvfZeSeTwwsMidzaUnEfKeg0QxgT+WvZ7pldSEBaUnjTeMJbP2jDFy9KnqBjQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:18.5378 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 527f3c45-d83e-4ef7-aba6-08dc58c88e7b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000014.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5659 X-Patchwork-Delegate: kuba@kernel.org From: Cosmin Ratiu Previously, add_rule_fg would only add newly created rules from the handle into the tree when they had a refcount of 1. On the other hand, create_flow_handle tries hard to find and reference already existing identical rules instead of creating new ones. These two behaviors can result in a situation where create_flow_handle 1) creates a new rule and references it, then 2) in a subsequent step during the same handle creation references it again, resulting in a rule with a refcount of 2 that is not linked into the tree, will have a NULL parent and root and will result in a crash when the flow group is deleted because del_sw_hw_rule, invoked on rule deletion, assumes node->parent is != NULL. This happened in the wild, due to another bug related to incorrect handling of duplicate pkt_reformat ids, which lead to the code in create_flow_handle incorrectly referencing a just-added rule in the same flow handle, resulting in the problem described above. Full details are at [1]. This patch changes add_rule_fg to add new rules without parents into the tree, properly initializing them and avoiding the crash. This makes it more consistent with how rules are added to an FTE in create_flow_handle. Fixes: 74491de93712 ("net/mlx5: Add multi dest support") Link: https://lore.kernel.org/netdev/ea5264d6-6b55-4449-a602-214c6f509c1e@163.com/T/#u [1] Signed-off-by: Cosmin Ratiu Reviewed-by: Tariq Toukan Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index e6bfa7e4f146..2a9421342a50 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1808,8 +1808,9 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg, } trace_mlx5_fs_set_fte(fte, false); + /* Link newly added rules into the tree. */ for (i = 0; i < handle->num_rules; i++) { - if (refcount_read(&handle->rule[i]->node.refcount) == 1) { + if (!handle->rule[i]->node.parent) { tree_add_node(&handle->rule[i]->node, &fte->node); trace_mlx5_fs_add_rule(handle->rule[i]); } From patchwork Tue Apr 9 19:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623082 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2042.outbound.protection.outlook.com [40.107.94.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F212157A62 for ; Tue, 9 Apr 2024 19:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689768; cv=fail; b=kQ3ar4xSRpwubSzFG5KyZQR8YLxFMWSK6mVhKYb8+qMObvwk/G5Sj3+EnTu+UgbutgMIsJDkpEA2OzGSJQaPOaH5IOFL1HPv2tolPCwoCOoIgBohT6neX8yr+JQ9VfchYmSiP2liqX8M6dCf3uFCfoTSWZCD+IulWnSZuV1z6x0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689768; c=relaxed/simple; bh=5eXzUkLVPGtqzNaU0aEC2pJXtIIj6cbIuN8bSoNthGM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t4Kag8lgvu2HCd3sxfzKsjTDA0ki0W8Rg5FD7wXDGT0bl+qaHUjCJLyLOGxx48DgdznVY181bS98gwJ9tx0rxq8EvA18ageGu/ghWnpax9DZ4Fsxp1Qlb98FKh9qHRLzazvGn/v+5eLys5eIDkEa54fUi3LaNEfdHEOHY7TDjPM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=L+ePXoe0; arc=fail smtp.client-ip=40.107.94.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="L+ePXoe0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFjYe4aaFW/4uxAxQX6iXUH2G16wTpGxk+vqWQjcOjBQ+uCg7yVtrwfCTVRK0WH+KeQwlnW2XxBt72zZkevXJQxYbTjNhOkOsNE2dG7dHNGI05Pyqj2hlSId0LW9Vgyb0NdGANcjEgGMeM2HTAp8xuUILLFq1ZsDbuZtqprWRUcfF1hJTXtDvWJER6IGnH9y4v98vhRwsqv5TF6TksqLOAXTdDlsMM9MXxAzCzhB+vZwbCvqLc4/sXIHqT/rmjqtEE7vgNX2CJSWCAfijX8uQP7En6sAt7DdcxK/AxxHLNstA2bfrM5gxdCp/F7k3RXsrYhkO0J+nFxruU2tc0OtSg== 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=UhLDx/vNc/T0y34K1oGVp1WEXu2dUl3+cYFnIMP/EMU=; b=cHOBgARkdb770NsoNkW3FC4CB30O3YCfzlF3WDjs/MWYxnifDOPVcUFx3d8O0TgWSZ8MLPlT+qssy+mp+DIURTYKlCb2yngrf5inD7Hd918qEOhKNWb+n7UlK+2lyceVz3Qlz5ffCvNfEVXL08MoZE2lb3PXeCJaoxjteULyJT8KjjYJUf+H1aegeYlX5v50xvGrFk42MUCUn5Vq1r86myex1BXzA5ktF/U+xwSphAuaShNqvNFs4Y4H/KjA4QT9J0E6iLGzrnwl8tEd36P8rERQ2hoK8qoYEya+w/cXZDAn/r12ezmBeTQtbYEAN4h0y2+6WwrqPleOEP+ALcV7uA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UhLDx/vNc/T0y34K1oGVp1WEXu2dUl3+cYFnIMP/EMU=; b=L+ePXoe0MpTCz/XrQgLp62XDAOX+gQsqW9U0JT5r7GIAAq4bFgoWpPCpln6c78fKhzedNTQoDRN1U/2pD6CiwNBjHEfqOxCLE4v3X6jU9S4VFlKz0PDwhTFH8ywwRtcUxtGA+ociCp1P8KBdgqz1HrHhoXppDhZf8cLkXZ61l50UrIxtJIh2HidPWNpUy0AC0u4euKsVyn6hJJR4CWPtBmYBlZIwb1Ms7yPeCE/WnKPqW1ussLOKMRPEYyFvF6roD+BK4sb0pk8N9LQ+fH5IxpQ6oeSI2NYAjYc9dE/LzI7P9KZ9CzHDMqurb4gx9ojknpE/YZEILQDCkQSzpir4cw== Received: from CH2PR15CA0018.namprd15.prod.outlook.com (2603:10b6:610:51::28) by CH3PR12MB7521.namprd12.prod.outlook.com (2603:10b6:610:143::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:21 +0000 Received: from CH3PEPF00000018.namprd21.prod.outlook.com (2603:10b6:610:51:cafe::16) by CH2PR15CA0018.outlook.office365.com (2603:10b6:610:51::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH3PEPF00000018.mail.protection.outlook.com (10.167.244.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.0 via Frontend Transport; Tue, 9 Apr 2024 19:09:20 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:08:59 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 9 Apr 2024 12:08:58 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:08:55 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Cosmin Ratiu , Mark Bloch , Tariq Toukan Subject: [PATCH net V2 05/12] net/mlx5: Correctly compare pkt reformat ids Date: Tue, 9 Apr 2024 22:08:13 +0300 Message-ID: <20240409190820.227554-6-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000018:EE_|CH3PR12MB7521:EE_ X-MS-Office365-Filtering-Correlation-Id: 42461686-8052-4ff2-9d39-08dc58c88fb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V5T9MaBWhRmej4Qfyh+MzjZgLxyqUhKZinZkuuyqUH51fRVyKvlgvuqSXRqtBtTqjeIh1cy+I7tpQ4suTsVhSOnWDYIXhzsYmZnG+V7FdxSf9mO9Rdnm/dkyiv0C3sWQI5gLwdKbA+tGgmgFf0LhdwW1KHbGERDNY9s2XwYRxqU2I6+iQhcaSOtmA0OQOiiJURZJF1OinzUTHwQfTQjy178gXGRuemvDf8XIr64w5iFd2xodWGSlK9iKo22xLE23EDCRfLzXwCHW2UN4N83HXJ2TAJiBvHSBm/MJTA9/+H2puyEXRAVgadge+7rwFM/xlB28NEpV6Xzo+eleRNf+gK7DAWAs05jw/aMyiUiOzb51GaqT4yeetR52HY79DE/YGL7wU0uXUBuKUPZFLsiVOfv0tkqXCJZyNTPgbZkPHtlNMiWnV7ndSmy6dyPl54yAXTSqojpzPmi2tL0u+ir/NDd5caRHN++Z1jlWdaTVnAoj22AkvzP6Kzd7WL2YFdjMDd+4qIp6WhZvWCu4qpxPITOFwsGu99E8RaRqUQkLtMPsP1ATirNujuuVxl1o3jeAovWaVpEaLziD7hKXHc+NvkmPhzKGAh4CkyODCeGX+1nXzT4N/LIre5W5aTqe9sdTT1ux22Q4rh3hkFxUGmeB+bk7rYx4D1aJxdJdvoiEYhY7PPbQWSxaXFW6E8Dx55q5lbyOeoGvLgdWPF0lzx+494t8SEXrUmUr8MDvnDjitAcjtWsLiSlIXDBbaUpZL3La X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:20.5821 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42461686-8052-4ff2-9d39-08dc58c88fb3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000018.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7521 X-Patchwork-Delegate: kuba@kernel.org From: Cosmin Ratiu struct mlx5_pkt_reformat contains a naked union of a u32 id and a dr_action pointer which is used when the action is SW-managed (when pkt_reformat.owner is set to MLX5_FLOW_RESOURCE_OWNER_SW). Using id directly in that case is incorrect, as it maps to the least significant 32 bits of the 64-bit pointer in mlx5_fs_dr_action and not to the pkt reformat id allocated in firmware. For the purpose of comparing whether two rules are identical, interpreting the least significant 32 bits of the mlx5_fs_dr_action pointer as an id mostly works... until it breaks horribly and produces the outcome described in [1]. This patch fixes mlx5_flow_dests_cmp to correctly compare ids using mlx5_fs_dr_action_get_pkt_reformat_id for the SW-managed rules. Link: https://lore.kernel.org/netdev/ea5264d6-6b55-4449-a602-214c6f509c1e@163.com/T/#u [1] Fixes: 6a48faeeca10 ("net/mlx5: Add direct rule fs_cmd implementation") Signed-off-by: Cosmin Ratiu Reviewed-by: Mark Bloch Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index 2a9421342a50..cf085a478e3e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1664,6 +1664,16 @@ static int create_auto_flow_group(struct mlx5_flow_table *ft, return err; } +static bool mlx5_pkt_reformat_cmp(struct mlx5_pkt_reformat *p1, + struct mlx5_pkt_reformat *p2) +{ + return p1->owner == p2->owner && + (p1->owner == MLX5_FLOW_RESOURCE_OWNER_FW ? + p1->id == p2->id : + mlx5_fs_dr_action_get_pkt_reformat_id(p1) == + mlx5_fs_dr_action_get_pkt_reformat_id(p2)); +} + static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1, struct mlx5_flow_destination *d2) { @@ -1675,8 +1685,8 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1, ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ? (d1->vport.vhca_id == d2->vport.vhca_id) : true) && ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ? - (d1->vport.pkt_reformat->id == - d2->vport.pkt_reformat->id) : true)) || + mlx5_pkt_reformat_cmp(d1->vport.pkt_reformat, + d2->vport.pkt_reformat) : true)) || (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE && d1->ft == d2->ft) || (d1->type == MLX5_FLOW_DESTINATION_TYPE_TIR && From patchwork Tue Apr 9 19:08:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623083 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2059.outbound.protection.outlook.com [40.107.101.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A46B157E65 for ; Tue, 9 Apr 2024 19:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689771; cv=fail; b=L1nN7CKKj+sD/6ufiLt3FS6DDZHkf/SS1jPbV3VvVX6qDcrzxtXvNcidygI8cQ10h33WjYOjwFl9lbH7m0ATCdM+3OIwYtEzSKKLN6eZqpb/Vtd5/F5pCLK89fh7iBGTHapKYCWPzxSF1APcCkX9HhSl7LUdIC6JuvOVG4l4u1Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689771; c=relaxed/simple; bh=iqCD/6960YC12G2CUmtyxfQ+cvFDR5yvwbz/Q9wx00s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eDado/BCS5jjT4DORiVa8d1FRNkRScKG/d4+YLytpa/VzuE24CZt1rvYILfj7/1Q1/56Vu8vk29BB2ZtPUOaruZ4i1GhD6lVt4B5/PrZG2jYfPlT+28Mp5Wr5VB177TTFzJNDenxzKzW/MWMPf7vhO507sWnrpGIJsPva379gQA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=SWSoZ2QM; arc=fail smtp.client-ip=40.107.101.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SWSoZ2QM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KtybN8jv12ccWltRAAeNCojEclJcRf3RX2Q/LgVdl1DLEg0HG7o8JURFuBGdsUb2SCZW2DCm19GltQpNHkN6I6cNxNP0069cEiiXGl+wRSVBJp6wLNUN5L/cm7oorz8A0Ky7Ib1difvvDKEUH7W0fwPIjTC0eDx0iOIqxPn3nilPlb5xizmkk9B97Q7QwyT+PtZKi7hqz2buUu4GdxRiGmEx+0eus2dC3NNCOrVAsY+Kw/V/uMddFmDUpD4pVVH3uwmXiaSB2aVmVniRX3Jrzd1ifo0D2YovGkSAwn90gXFpiyZLLhLNQkLLSmC7PZsrR6G3028BXXJbQM7T6yV0Nw== 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=woYd8/OOt524EU8k9kXzn2pVuRstMA9/5xU5uP8KSik=; b=heO2HlBRND7FEi4DzuG2eMIqgQ6cbrrl9tBbZHlBjuEfgzyGUkwBlxZFQXeVG3Gf8u/HIy0y5dX8vNJSWd77BZU/i26ObR8sBkgAcyqLuEiwjTtlT9sxPmIJ6IHJ1nhXYmYuJRC4hnA+tBLsQs43TWOB6F8QKHCvH1tN2WpSGKtV45SxXer0rW8RVIxJ0ICJk68R5SNr3DDJNw89Y8ErhRyOGFdob7RuKtqgZf3gVZhXqclc58L7Mg7UqSJ4xRrThlYtnWJ2mukvJ2h7J+wd9RzXsmegDLFkCOoLkEbUuZvtkPBOIiqRv0rZGk9snRcjRg8ES01imZb6+TR5R06jtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=woYd8/OOt524EU8k9kXzn2pVuRstMA9/5xU5uP8KSik=; b=SWSoZ2QMVDIOmk2zmw5QO5cT9yKYoIOC1Gkj8hAkedbJtpIszmb2c+MppMuo99RYua+j5rd48ANJ/iMfZlRQFmVTUFIfShb5naj3QsNh/iEMi3ZJET5SZkwBKrY7+oxq8IfYoaeSrbZpLSSJA7dlMrDJkefhaQne9iItECb5eR0K5Fx8luJYVcaq+aaJUBC2jGkamKJFaCC4sJrlypJUThLlT6n3uYy6EAKaK9KB7slIDzI2kSaV5nIUcyd7CgjXm+wn/VTp2kLeEbcylvYM2/Dfm5orZaO6mpvZZW0XsuGE/tWtb/WeDVPGZU4pLnwiFqtzQvbwfoyiHl94NOUBqA== Received: from CH0P221CA0032.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11d::11) by CH3PR12MB8187.namprd12.prod.outlook.com (2603:10b6:610:125::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:26 +0000 Received: from CH3PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:11d:cafe::3a) by CH0P221CA0032.outlook.office365.com (2603:10b6:610:11d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Tue, 9 Apr 2024 19:09:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH3PEPF00000017.mail.protection.outlook.com (10.167.244.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.0 via Frontend Transport; Tue, 9 Apr 2024 19:09:26 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:02 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 9 Apr 2024 12:09:01 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:08:59 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Carolina Jubran , Tariq Toukan Subject: [PATCH net V2 06/12] net/mlx5e: RSS, Block changing channels number when RXFH is configured Date: Tue, 9 Apr 2024 22:08:14 +0300 Message-ID: <20240409190820.227554-7-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000017:EE_|CH3PR12MB8187:EE_ X-MS-Office365-Filtering-Correlation-Id: 800d959a-7e46-4386-40aa-08dc58c89323 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AdMecxhCihLrLitFYzpEPvRdoogFk/d56wO8wQTpRQHeUyfJBErN67j1Xbjq4Tm+jUUZNdMILvPgmcEBUoaBwNxSlWsSK/SkR+pCI4vf8tURqeYwoWTxfu7nzbdgFzTbc4sdkAnDdR3fLZQHQYCNDGXYYB37jxquaFi7h0rtmjaxa7tUa378oGXqfuOog2+9HXxtJpprEgp1hUzz2A1Ni/3zrPbJI44LlkyH/iDvk0RXFqKaCN/MkDSbQFg2SU4QpfYri/L5/zZIMWelLLhwM+Xt1vi9xFCym4SNwmrjuXfi97Okdb+9xKSXwWTERrQlPEvoa1h6QV/FBtDsCcQ+KgcwAwYvnlPAssEMZWrBc3IZhpMwVzKJA/Um2ZE1YiurSrKDMMen63pZczHhs19cpuM+DlIpa/trFWHQhsZjwMLfC6u5fTcKnt6jFbLR8F5Y13pHiqE30AOJ7ggESdIOmvxEnw8xkEdDeczMRq2DgHcp1qPi34iohv4RVPRyCvq0QkO6wEMpRA6O9Kw9S4HULIvO2jzD6JePcoS4Vk++2yHzMCV6kS/tyNhc1QDpHbchYbr0PWP1dg2tA123RztxuFWJ3NQATgA/+GVaiQutjbHfKovJRXkLe0q1q4+sFPFF2dsByBbR1zSH5hAYPvYCBG5BwEc8smcnVtdvwV2WekSMjKxzoYsuMFzJyDyWHbyUcaNSp5ragp0Kx3d2+Pgh8sWYYFMg+Cd2sR1aNIytyow= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:26.3313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 800d959a-7e46-4386-40aa-08dc58c89323 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8187 X-Patchwork-Delegate: kuba@kernel.org From: Carolina Jubran Changing the channels number after configuring the receive flow hash indirection table may affect the RSS table size. The previous configuration may no longer be compatible with the new receive flow hash indirection table. Block changing the channels number when RXFH is configured and changing the channels number requires resizing the RSS table size. Fixes: 74a8dadac17e ("net/mlx5e: Preparations for supporting larger number of channels") Signed-off-by: Carolina Jubran Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index cc51ce16df14..93461b0c5703 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -451,6 +451,23 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, mutex_lock(&priv->state_lock); + /* If RXFH is configured, changing the channels number is allowed only if + * it does not require resizing the RSS table. This is because the previous + * configuration may no longer be compatible with the new RSS table. + */ + if (netif_is_rxfh_configured(priv->netdev)) { + int cur_rqt_size = mlx5e_rqt_size(priv->mdev, cur_params->num_channels); + int new_rqt_size = mlx5e_rqt_size(priv->mdev, count); + + if (new_rqt_size != cur_rqt_size) { + err = -EINVAL; + netdev_err(priv->netdev, + "%s: RXFH is configured, block changing channels number that affects RSS table size (new: %d, current: %d)\n", + __func__, new_rqt_size, cur_rqt_size); + goto out; + } + } + /* Don't allow changing the number of channels if HTB offload is active, * because the numeration of the QoS SQs will change, while per-queue * qdiscs are attached. From patchwork Tue Apr 9 19:08:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623086 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2874158A18 for ; Tue, 9 Apr 2024 19:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689777; cv=fail; b=UMPz5vP7Y8DVT6Tm+giA4kP8sYgsmpT2vtlsZhsJi02u34z+OLhSkMXpLacEyjGM5KAxwlPXDO12PcJecixi42GluRcfBgt2D0GhoxIfVoJikn0G0P3yfgQ3UjCpWmbROWocgu4fciAQHFqzm8pmEIKssGy9D0xpzYYZi18hGZE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689777; c=relaxed/simple; bh=FNTXBJHyKqGhgSS4tT/jIIL419Kx1SevzDJVIzTcMoA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hGc8n1VsQ5W2BteKcHrMIQxis1kL5lWvH5qtqTmxyQADWKepLjGmmqjcIuv/5QTOuilmafOShlne9xbeoeyXbbBbZuIsLUZ0DP99BR+cAd5DfRrIeUkFA8m2w5C8kvnAmqkMoVBsnH4yFSyw+PMPATkt/KkdKQWU1hql4OzfqDE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=DZwUyobC; arc=fail smtp.client-ip=40.107.220.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="DZwUyobC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iS2H97fTkzmrQtIiRL+DqX7mbzRaEGzB/+btbx+LwHmQeyhRoIN5Z5kF6mc7NhBtXbTx+LvY3kOMVKPCvVy44kyI0nzLkYQjZHzsPBkqANWhC/2JUVd/tqwQ0xxViXpQPTcSXLcc5sKk0LaR5IvBh102E3Xj7QkZnubL5wcldJxaiiHkJeEyX5r5JMM1MXJ51BD9Vp+ZqBTg9RrjWKT3s6ddNVkRj9B1QqNGeGhzWjr8+4zANZD8B7vcLqd3yfOsYp6jo4FPVbNB/LigiJ3MURMxJpkFjmlu398IYbXdbCoBwJEHBjqiWI5ibmAjBuCi90eUFz6rW4MyAbDl0olD7w== 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=QrYU7qhD5C7Sfj+JoJkZMIImW5B1nGTsAhEKRpSMpTA=; b=UXgks5P0BKWCP5qzP8VGqGotTDoYUMGJ9eTCqFibv1mKx5f/VdibvH/KEzC9Vx5BXuV2gn6QxVpzyfQSTMdp17myDWwISEWeQ4wQrAMsyEST7hekXoSt+6TD8XY/TTdFKL3OU2sKvt2z4g2u64h7Pu10zXJactGm/EsGQWnD8Qp9NELZIv1c6fAJWwheoe5tYd3zV3mCbkmB8j2o2Fb43MCf0RbuNCG7IgZ5xPVAdMSOVsIgUnkn33b8mEjgwZG0sJm9TLfhDJ+Y0YbW7eUcNkXsFu2kqAxQ6D6m0j1gs8ROSYlnzRMGvUTxN42EJrz7JWQ1wI4GrebPYOUwWwzxqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QrYU7qhD5C7Sfj+JoJkZMIImW5B1nGTsAhEKRpSMpTA=; b=DZwUyobCvgz3PGW9lapQKMH8a+amdZgHkstpbO97cKjpnvLYbU6yaSRmJtcubbAhKYLWCHpxZ39h+MSU8CX+A6plvDZi+t5EqTguDWJM15Eq8eJ/O9zpEf3kx/blYD1MJavGyIL1S7WR41bxuHx+/RDSEzr8LnYM5BqEGbMxSHFBVKHxHbe44l79fXwedOFmL/miQYE0SE9GNvzA3/yZmWwHaIfQY0Rmn8+QlMdu89JTK7ZoC6cZ6Nbn9fsezlie7P4LCkmlZBSmasCpXUv+kaWot0AnmqYe6YfoLvoN1F0nVYrHCnZ7sbp/vlcG59slCFU0dZ7N6+xWQBDBFFHDGw== Received: from DS7P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::15) by SN7PR12MB6689.namprd12.prod.outlook.com (2603:10b6:806:273::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:31 +0000 Received: from CH3PEPF00000014.namprd21.prod.outlook.com (2603:10b6:8:2e:cafe::14) by DS7P222CA0012.outlook.office365.com (2603:10b6:8:2e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH3PEPF00000014.mail.protection.outlook.com (10.167.244.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.0 via Frontend Transport; Tue, 9 Apr 2024 19:09:30 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:05 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 9 Apr 2024 12:09:05 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:09:02 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Carolina Jubran , Tariq Toukan , Dragos Tatulea Subject: [PATCH net V2 07/12] net/mlx5e: Fix mlx5e_priv_init() cleanup flow Date: Tue, 9 Apr 2024 22:08:15 +0300 Message-ID: <20240409190820.227554-8-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000014:EE_|SN7PR12MB6689:EE_ X-MS-Office365-Filtering-Correlation-Id: f71e3b6c-569d-45e7-18de-08dc58c895c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KUCWJW29jgbhHmUtDtM6Z/HWhg04HOs09aIjz8edMVZu63nYceWG2m0cy+hOZiVfEg7Lob4Uw1JMfsjpKhoSO+PMz9nSL3b7k31RE3l/afloZBNSZs1oDmjLCMibXSXM80w3VGxJid2r7w0m9joSN2YvElhjQSxZLHbPp7br3m8y3kaHaRKXQMtK7qamroZtTnZv1bLRJAVCDwG7eXekPpKmuMfx+ppZnU9TwAskZOX88rhsazGeKHpVTOqSIxYzF8vPllsrCe0sl9nS3pmcbFgIZneRdrIW1xKb8/R3qPvQIxOgQZy1iZAtrUJ9z0/gCNFWOYTV9jwrWWAcn3h21dIZDCYqDM2MQ4mdU+CDH+uKUrwuCcu6d+8zfCLba0QLVo5VvZlVi8+k80K/4rKqTOoGwNOHqfC7WN7+8GFBLdKKamYVDVIR8ILLDQJbEtpiTagzrnsmdbekUZ/jeszbIbyN3uQ+lXw2y8SHVNCzTjCEuNFe1//fDyLzh2TxSjEJkYR2KG4no2mxD5vgVUEHsl7bWXJS5PuNlLB0VjLs2Q6rpMNQZDMqcuK628I3lVSofBwzDUqdjlURCKgGg+xfpojTC+4PAEDdYLrbp/xp99I8aIO4UtSVMmK48fe/qOa8bcr0lfQXcyiAt75zFqPp3sIOd1QMyzdfmDLITzT0L6Etw6GGEWV4etCbseTBF3EW7rFarWY0IuHmCpqKqYFvPzhpxJSP234KNGYRpbiW05g= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:30.7565 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f71e3b6c-569d-45e7-18de-08dc58c895c4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000014.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6689 X-Patchwork-Delegate: kuba@kernel.org From: Carolina Jubran When mlx5e_priv_init() fails, the cleanup flow calls mlx5e_selq_cleanup which calls mlx5e_selq_apply() that assures that the `priv->state_lock` is held using lockdep_is_held(). Acquire the state_lock in mlx5e_selq_cleanup(). Kernel log: ============================= WARNING: suspicious RCU usage 6.8.0-rc3_net_next_841a9b5 #1 Not tainted ----------------------------- drivers/net/ethernet/mellanox/mlx5/core/en/selq.c:124 suspicious rcu_dereference_protected() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 2 locks held by systemd-modules/293: #0: ffffffffa05067b0 (devices_rwsem){++++}-{3:3}, at: ib_register_client+0x109/0x1b0 [ib_core] #1: ffff8881096c65c0 (&device->client_data_rwsem){++++}-{3:3}, at: add_client_context+0x104/0x1c0 [ib_core] stack backtrace: CPU: 4 PID: 293 Comm: systemd-modules Not tainted 6.8.0-rc3_net_next_841a9b5 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0x8a/0xa0 lockdep_rcu_suspicious+0x154/0x1a0 mlx5e_selq_apply+0x94/0xa0 [mlx5_core] mlx5e_selq_cleanup+0x3a/0x60 [mlx5_core] mlx5e_priv_init+0x2be/0x2f0 [mlx5_core] mlx5_rdma_setup_rn+0x7c/0x1a0 [mlx5_core] rdma_init_netdev+0x4e/0x80 [ib_core] ? mlx5_rdma_netdev_free+0x70/0x70 [mlx5_core] ipoib_intf_init+0x64/0x550 [ib_ipoib] ipoib_intf_alloc+0x4e/0xc0 [ib_ipoib] ipoib_add_one+0xb0/0x360 [ib_ipoib] add_client_context+0x112/0x1c0 [ib_core] ib_register_client+0x166/0x1b0 [ib_core] ? 0xffffffffa0573000 ipoib_init_module+0xeb/0x1a0 [ib_ipoib] do_one_initcall+0x61/0x250 do_init_module+0x8a/0x270 init_module_from_file+0x8b/0xd0 idempotent_init_module+0x17d/0x230 __x64_sys_finit_module+0x61/0xb0 do_syscall_64+0x71/0x140 entry_SYSCALL_64_after_hwframe+0x46/0x4e Fixes: 8bf30be75069 ("net/mlx5e: Introduce select queue parameters") Signed-off-by: Carolina Jubran Reviewed-by: Tariq Toukan Reviewed-by: Dragos Tatulea Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en/selq.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/selq.c b/drivers/net/ethernet/mellanox/mlx5/core/en/selq.c index f675b1926340..f66bbc846464 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/selq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/selq.c @@ -57,6 +57,7 @@ int mlx5e_selq_init(struct mlx5e_selq *selq, struct mutex *state_lock) void mlx5e_selq_cleanup(struct mlx5e_selq *selq) { + mutex_lock(selq->state_lock); WARN_ON_ONCE(selq->is_prepared); kvfree(selq->standby); @@ -67,6 +68,7 @@ void mlx5e_selq_cleanup(struct mlx5e_selq *selq) kvfree(selq->standby); selq->standby = NULL; + mutex_unlock(selq->state_lock); } void mlx5e_selq_prepare_params(struct mlx5e_selq *selq, struct mlx5e_params *params) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 91848eae4565..b375ef268671 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5726,9 +5726,7 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv) kfree(priv->tx_rates); kfree(priv->txq2sq); destroy_workqueue(priv->wq); - mutex_lock(&priv->state_lock); mlx5e_selq_cleanup(&priv->selq); - mutex_unlock(&priv->state_lock); free_cpumask_var(priv->scratchpad.cpumask); for (i = 0; i < priv->htb_max_qos_sqs; i++) From patchwork Tue Apr 9 19:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623087 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2077.outbound.protection.outlook.com [40.107.212.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AAB3157E78 for ; Tue, 9 Apr 2024 19:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689784; cv=fail; b=mPkP5ER1dFB4TP7IT+BwtlyJGADbGg93q/13rnJ4X4tZj0tL9JUAqRgoPeJo+avxg1Y4g3Xm079toYFA8e4wiZb08Q4y+cWR2RFjutl3DOQjhb+qO/Pr8Ea1B6nS9jMIneScs6dnldbae396ONfdWRPh+UF3pwoSIpdQ9aZQTvc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689784; c=relaxed/simple; bh=BbWEOlKhG1WNIfZiKHn8H+LrWwtAboEi+XniGsTqvhE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t2RclLR4BGOs6DS8xhSTDBOyaQrUqvID1hb3XIbA6YpOcTPDWlDCgkGn6e2najITEmIq6jt48Qzx/I+eDbG7ebAGLGKY2GY/qQZ7THxzBnUMGVFX0YJVAxQULj0TAaIohwvudRYKsHvnk8PcOgynsXd9Xmfhoimt3Dv7EqfiOJc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=jmYfA65z; arc=fail smtp.client-ip=40.107.212.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="jmYfA65z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PG907Vg7Kx4J+2gjzX5/rQKAnUQx1fHcZLFyqxCGVrnefSdYrkxLQjFTE2LoEMPBoypLgl0S9ee0w+vxRZvjFI4Ym1MjClsNkqklNRSmVqxmwATatrYsCCTuVWShLOpnlUU0u/j7aOF1T8a8tf6oi8A2R8XxJpntrO6ngrqvgiuM5wZuSc6RPTUHiTqv8ptjEPQYkrSPD7WZHxyytaZfJf1s2U/EZ4gupK0usyzBRIi+7h11/njIbrZ6+OmW/oXtnWwnWX4Y1iayhH+s8eRv12QLF+pONnBe42Ffh+H3T8OwdypE7sqh7X/6hH5YJ9mxgm89cejUxHCNaU7Qy779Og== 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=+GVdnVS/JjAOrgCywukcyKXjoUktu16htUsYUtDwoE0=; b=bIEEJk/pHwI9057GTosIJp5s2rk25U0BKiLOaPwVV0Ijqpk/UVvl4KAiikdJDoXOjlVR+lXSjXkgewBEXAH0zwdBz0CwmI60cfnpbclwf95O3YDuioqJ+q0b3GOLb+86lpq39Ebkr0AhXtQXVDq44vRO8MwmEzklVcW72lMS2JsfHaOm5zP3+ytCc+7mf5o0PRJ2gUIt+mS3x2kkupP80jC+VjziS+ijfFtsKqGm019STuFdC+A92sQeqceWdk9qjjXY+CFEiN8itZeiSfLq5hD9HMMjxH0+7k53S/uvZneXTg0Iqp37GcDM2+daZuczw0iyHU/nnzEBE5w7O3Abwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+GVdnVS/JjAOrgCywukcyKXjoUktu16htUsYUtDwoE0=; b=jmYfA65zUWGtLTPirZl5M4fD/Ib2C/ijwqd3lKx3sqXl8/QQNmNcOhVfcI4bZ91WTmLrgXhZVP94JERI3Ij0dszWoGQH5RX7QGeZ41si2d391RIUqkaWAmWF6CMJ2IHQsoWzGuycRFz/FDgDKBIN/Ix3KtOocIbhhomnu88TaQLvEtUUadH/QJn/o3LAifAqD3SigZUHLvu7kzp0aeqjNWziUDO5NCVDVm2EvxU4cmTxrHysjikxSMmRiIgSGls2T3vt0VGrZfUVmgYoDOfX4HKrdZkHN6rbkw9Lroo8gciWWnLSCLnHRoPk3g35qWgfvBQYS3BxhnLRvp9toD2Xcw== Received: from MW4PR04CA0362.namprd04.prod.outlook.com (2603:10b6:303:81::7) by SA0PR12MB4429.namprd12.prod.outlook.com (2603:10b6:806:73::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:38 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:303:81:cafe::de) by MW4PR04CA0362.outlook.office365.com (2603:10b6:303:81::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:37 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:09 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:09:08 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:09:05 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Carolina Jubran , Tariq Toukan , Dragos Tatulea Subject: [PATCH net V2 08/12] net/mlx5e: HTB, Fix inconsistencies with QoS SQs number Date: Tue, 9 Apr 2024 22:08:16 +0300 Message-ID: <20240409190820.227554-9-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|SA0PR12MB4429:EE_ X-MS-Office365-Filtering-Correlation-Id: f9585fb8-8bcf-431f-57ea-08dc58c899bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qSCwIA7QSWcSnq992ech6k9fkb9zTMqrdOPRYhmQ/fCUPhn03XhirT48rOZF4wk+MdKVlRWjrgpH//j8Nsvh1lfG8DMSKBalvc9dnNEvvLRS3j2XkrLrCgBpnoEqPLBJ0HQA6U6UFFwlndyHSFZA/gPpbbcXnv4QcZQ2b0Z/UpkWCqZYc7PH/nlmJiha5cAh4ovWkaYJBmT1o0KEIdKkkYxy0tLe6t2nO1BZJbB3qAOo8U16sS96pCNtWex0kKdV8ydNdAPgzv69+76C7SnDRJELVFztntHuPJVsotQcLyd+o+9PXUjdlkZYc+y9FIyfhy0L6S7ekw8wZg73/9DTA+CP5gjibzOloOz5i9w7v6D8N20+v4QOFEYKuskRwKvt9x1ejxLwLg0HJpR+9ygfjo5SnGdYYZTJdH+rAUx+rXoUgsENsepomKk4vhH6ssukvMelN58X3n86kBAUIXbOCJBSaiQHVFlE+Afn3uGmV2MIMgKJoJNlobFZMhuu0/LH19NARfgdujBBIQnVm5K/faFugxoaEJmWvxrqVLgLyhEIF3IcTHqzuZhWBH32z+ovzrHkvGolOnr8krPLKRnoJq7Dww97WyWX26qBaC4FUtNWqeEluEV67+EZfw/GXvn8HrgzYIVQwH8nz1waABy7/7vaMQGM09K5qBSAJP9XOw+FnVUuDRcjxXMS0W+QXjuOrlK1LxlAwrhxlMtj8MHf2xqmFU6bL9fOWMtynS9rG9wZmfwRAC8wRGrI4QH2OMZF X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:37.4231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9585fb8-8bcf-431f-57ea-08dc58c899bd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4429 X-Patchwork-Delegate: kuba@kernel.org From: Carolina Jubran When creating a new HTB class while the interface is down, the variable that follows the number of QoS SQs (htb_max_qos_sqs) may not be consistent with the number of HTB classes. Previously, we compared these two values to ensure that the node_qid is lower than the number of QoS SQs, and we allocated stats for that SQ when they are equal. Change the check to compare the node_qid with the current number of leaf nodes and fix the checking conditions to ensure allocation of stats_list and stats for each node. Fixes: 214baf22870c ("net/mlx5e: Support HTB offload") Signed-off-by: Carolina Jubran Reviewed-by: Tariq Toukan Reviewed-by: Dragos Tatulea Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/en/qos.c | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/en/qos.c index e87e26f2c669..6743806b8480 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/qos.c @@ -83,24 +83,25 @@ int mlx5e_open_qos_sq(struct mlx5e_priv *priv, struct mlx5e_channels *chs, txq_ix = mlx5e_qid_from_qos(chs, node_qid); - WARN_ON(node_qid > priv->htb_max_qos_sqs); - if (node_qid == priv->htb_max_qos_sqs) { - struct mlx5e_sq_stats *stats, **stats_list = NULL; - - if (priv->htb_max_qos_sqs == 0) { - stats_list = kvcalloc(mlx5e_qos_max_leaf_nodes(priv->mdev), - sizeof(*stats_list), - GFP_KERNEL); - if (!stats_list) - return -ENOMEM; - } + WARN_ON(node_qid >= mlx5e_htb_cur_leaf_nodes(priv->htb)); + if (!priv->htb_qos_sq_stats) { + struct mlx5e_sq_stats **stats_list; + + stats_list = kvcalloc(mlx5e_qos_max_leaf_nodes(priv->mdev), + sizeof(*stats_list), GFP_KERNEL); + if (!stats_list) + return -ENOMEM; + + WRITE_ONCE(priv->htb_qos_sq_stats, stats_list); + } + + if (!priv->htb_qos_sq_stats[node_qid]) { + struct mlx5e_sq_stats *stats; + stats = kzalloc(sizeof(*stats), GFP_KERNEL); - if (!stats) { - kvfree(stats_list); + if (!stats) return -ENOMEM; - } - if (stats_list) - WRITE_ONCE(priv->htb_qos_sq_stats, stats_list); + WRITE_ONCE(priv->htb_qos_sq_stats[node_qid], stats); /* Order htb_max_qos_sqs increment after writing the array pointer. * Pairs with smp_load_acquire in en_stats.c. From patchwork Tue Apr 9 19:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623088 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DB75157E7F for ; Tue, 9 Apr 2024 19:09:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689787; cv=fail; b=VUAK/6nvRQGtFHHRrfyI+oPVHQ0NUGeqQZs4T4T1WodxiIEYj7jcmEBRaCZn+envdOLtF70pigbgAwYFm9kBzR3Llt4owIIFIwsdV9igWB6cyCCe1mmzxpiMOzhYtlZYS6gPt5tUKo2RAlLwGW9kAlsObwxr4ztsZYfodPBaeFM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689787; c=relaxed/simple; bh=SoPWldYEMOLy0LFHbHVw7F2k9zWrI9mszqSttOvK5vo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HjbLDgf44SW0xnbdYaO/3iOtoeyrMcgBl5YhYvYO1uzZvAPdmYKF0hIHTfXXIhChF/kr9/JpfvXe069zNM4N/hmOWztYdy1qs1BELk84wAPxCbWGHDzOT04luoKSFhnBJ+uev7ddlo95RLaCt0oFK4ivTc30Sy+I+s+5vsMGRWY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=N+Aa+/cH; arc=fail smtp.client-ip=40.107.93.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="N+Aa+/cH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IS5Ne+VOc6GmSwj2bd6XpMVCN+TgccR113JktiTSyPJFR/oxdr/FYKUw88pkn2G/2+mEP0nviNBZWZPSULYMwh4imsIz8blGplOgO3UO1ujG3l/xTCatBNaBzqLc/GFgaaPCYLPREt9mxbYhdm3qG/+3RLIFNhoMBKQHCow/Yuw0xiSLPXF8Uw/thekEICgluue2pgkriYbbWgvmNJA5qlftk9EEKD3GMAAubY8z4xWrlvQJ1aKVqXMx4ioUxbGA4/riUhuz5Gff+osBHp1FZFKfzXtrMgURPD1rLH8ZDhgtVp72iL4G6Ml6gix6Vd/jbmX266zvAbhXBppQbQPclw== 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=+XllesOPOBqKXZhUR0SL3sQptZ0yO+05IjrINj7jYog=; b=QEB4HSHE+THMwJnqCBWyqPIBxTriK9UaR2Ue4naidOl9wMWEmwEZHzzALmHmBWvFEExLlyB8Tay7YlquoRnMCmlZOxE3peTDFNk1cUe7b6FYDc+MGA39DwiumWsYW+GqnhBCjbeVRpoKm8vJ3Y84cWsSVdBWhVmNBcWB+1de+fUsfXqhpTFucXIy28Owws/6nwn2Gf97DsySCt5urYrswt2upNpSBNQMgiZa9JJgV604h1ZmaSArymFgxqiIBQH7Q0JuugH5cuPOgxpg+q/1DLCGTpAPWuMCEUJxU5CapfciqvIr7j8tfx9dxVNTrNrQTEXLaTxx7qA7inCJbLppaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+XllesOPOBqKXZhUR0SL3sQptZ0yO+05IjrINj7jYog=; b=N+Aa+/cHion7L9Nsq9SdEHJ3F2FhALMtvkLf+s6KFhAclyzBozsHz3HDInHgxSScvxFr2VIrQgsJ48evCRwZdrbd21PxsdT5fsWE8w3lTJru3OixBO9cGiQJ/Wwh3tuJ7EsIyTnE1tNsyhDKon1ZYSlFw0B2gsu0VsDzjoPBnGYsQS0BxvVZgAFqp3b8qDP3ml/IwDZrnx4MiaiSvY3tIZZWUnVtqPgieI85fg+GtIn2ML8y/TpMQ/SmUp9es0BP7EXXkDYrzSOG8C5rZYZwUMNkPxcTuI/WWSMjNLHlemY2MU5Za3H3neq+6e7Ydk65LHdRocq1Cp66h/AzMDmycw== Received: from BYAPR02CA0017.namprd02.prod.outlook.com (2603:10b6:a02:ee::30) by IA1PR12MB6236.namprd12.prod.outlook.com (2603:10b6:208:3e4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:40 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:a02:ee:cafe::f5) by BYAPR02CA0017.outlook.office365.com (2603:10b6:a02:ee::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:39 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:12 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:09:11 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:09:09 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Rahul Rameshbabu , Tariq Toukan Subject: [PATCH net V2 09/12] net/mlx5e: Do not produce metadata freelist entries in Tx port ts WQE xmit Date: Tue, 9 Apr 2024 22:08:17 +0300 Message-ID: <20240409190820.227554-10-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6731:EE_|IA1PR12MB6236:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d48952a-d75a-441f-1dac-08dc58c89b0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bqZ8oeTtgbMat8D2iQo0Us38ZUvmgMEH+RI6T/UoHe/1WpM0nTtmK/tk50ZIvDHyflcLVNCnPvipImT85J27eREDdIConMynjh3dACZFx19Dw4kFVSzYduDlxNto2eDXj6nLUIDsKHyeg3LW7i6Q9JxErD7/rLLU4MC7d8mF8p00JVstv+l8ZirGA1ZSW2E0ba7qIqrc+Vj9hSKI9TZFnWCMT4i4jeEORxoaWWSHW4x008QFHnMAqqsqe0fQjjUSuezCXQNIl6wdgtYRCF+nqIz/HmonakuBnI6TgxKUbLuNRYm5hcGLdaF8Sllo+DskQOHA/Udpfv/e7Bu0vJXNomqqKmQR9ALs9GsKSzIQ97ht7B/fe92rt/oKh5prT7a7Goz0jD9Qrd8AP8AtM+AfMCw5NjRojXKb6veUeNH0mUEh6fLP9aUlkvReSjp/0OvCOr2JXNSDYCF+8pg7EcUnZJ4K9QNj5zEsI/OaBVk1KzWy6smH8hhlCc8R/r7+VkFAGN0/xXzbz/09qmjoB72FM1zAdZmG397sbNz5CO05WEmzSJCS2d8B5UPjKO+KKwD2bfGMM7+QZp37fEtyGr/tdrN3tBzQxfugqOOUmJYMYEFftMRHXTbjZu9Ug9aeS73SPGYZwoBI4aSlEWMLi9lvujw1dVFZGpGDwntyuAYbZJMXNsmD0zJ1Z/KPlIOl4NdPJovTk/6tM/vfuezad4UKLcaqNEAqgrlBzhMYmiZYHXTr8EPzWgIHW4JHCDqdB3Ul X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:39.6040 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d48952a-d75a-441f-1dac-08dc58c89b0a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6236 X-Patchwork-Delegate: kuba@kernel.org From: Rahul Rameshbabu Free Tx port timestamping metadata entries in the NAPI poll context and consume metadata enties in the WQE xmit path. Do not free a Tx port timestamping metadata entry in the WQE xmit path even in the error path to avoid a race between two metadata entry producers. Fixes: 3178308ad4ca ("net/mlx5e: Make tx_port_ts logic resilient to out-of-order CQEs") Signed-off-by: Rahul Rameshbabu Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h | 8 +++++++- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 7 +++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h index 86f1854698b4..883c044852f1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h @@ -95,9 +95,15 @@ static inline void mlx5e_ptp_metadata_fifo_push(struct mlx5e_ptp_metadata_fifo * } static inline u8 +mlx5e_ptp_metadata_fifo_peek(struct mlx5e_ptp_metadata_fifo *fifo) +{ + return fifo->data[fifo->mask & fifo->cc]; +} + +static inline void mlx5e_ptp_metadata_fifo_pop(struct mlx5e_ptp_metadata_fifo *fifo) { - return fifo->data[fifo->mask & fifo->cc++]; + fifo->cc++; } static inline void diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index 2fa076b23fbe..e21a3b4128ce 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c @@ -398,6 +398,8 @@ mlx5e_txwqe_complete(struct mlx5e_txqsq *sq, struct sk_buff *skb, (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))) { u8 metadata_index = be32_to_cpu(eseg->flow_table_metadata); + mlx5e_ptp_metadata_fifo_pop(&sq->ptpsq->metadata_freelist); + mlx5e_skb_cb_hwtstamp_init(skb); mlx5e_ptp_metadata_map_put(&sq->ptpsq->metadata_map, skb, metadata_index); @@ -496,9 +498,6 @@ mlx5e_sq_xmit_wqe(struct mlx5e_txqsq *sq, struct sk_buff *skb, err_drop: stats->dropped++; - if (unlikely(sq->ptpsq && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))) - mlx5e_ptp_metadata_fifo_push(&sq->ptpsq->metadata_freelist, - be32_to_cpu(eseg->flow_table_metadata)); dev_kfree_skb_any(skb); mlx5e_tx_flush(sq); } @@ -657,7 +656,7 @@ static void mlx5e_cqe_ts_id_eseg(struct mlx5e_ptpsq *ptpsq, struct sk_buff *skb, { if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) eseg->flow_table_metadata = - cpu_to_be32(mlx5e_ptp_metadata_fifo_pop(&ptpsq->metadata_freelist)); + cpu_to_be32(mlx5e_ptp_metadata_fifo_peek(&ptpsq->metadata_freelist)); } static void mlx5e_txwqe_build_eseg(struct mlx5e_priv *priv, struct mlx5e_txqsq *sq, From patchwork Tue Apr 9 19:08:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623089 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2081.outbound.protection.outlook.com [40.107.236.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 625BC158D75 for ; Tue, 9 Apr 2024 19:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689790; cv=fail; b=bnyhRK0Wc0G+fa3JOWOyxbvHt8NUr7W07S/G6o8j/TklRBvZlH16Vkih6tUJbzP+Z/3mAVJcR5oO01O+BxY9j6XSDnn67XJi2EYB7wYGGiIMKt9VWvNJ0Ww7noFO6LEtJOWBLLhfpZbCNvqtUjSAo7XtwwTRsp6iugSW4vTd4GE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689790; c=relaxed/simple; bh=ULGG/+HW+Ir47pk4qupjHdh4j83Xx/hBiXL73OlcD1k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fJpSS99Y/mFw2Xp4pBVqYYxPoXgX21cD38c5m9wiNr0LgXgV5NfUaAoT/+Ey+O+4XW0l+ELYqXfKgd8puy4bXq0wUYArsfBDBuTe6hjBK1ko0u8KoXVOrSIBDjDIqnBeloxQybq4fnGVCvmmYJqag5t38kmz0w+feuIDWuJ8J6Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ap46E3o/; arc=fail smtp.client-ip=40.107.236.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ap46E3o/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ObxwEAUgZgclV2f23sNuPu1A17ZdzhImsTydRwgzj97psBV0ohjgG8jEAfkDOOkmwiqbSz2HpKHd2Tn7RYdjGm18OmsZfEBBrMpR/fMSOWFkddS8S+97fkCdVravyU6GozTupxoHSun5ZLoTF7nndtzSAsjtdJOy5bYvH9TZEp8XXvtIB1f2obtQS43ZS06JuFTbb+Ss8Qef2FhaJD40wb4M8805QyQ2bDQZjYQUi+xx7B0pPi6xEPavjMbPq3N2jwLvhuJyBCJfg/9Td5cunl1AAsgCiDTmXZdOIqPJ2TrqoEBHaH/JJs3OG4PQXAjWG4/kY94Yla6LoP4zpqVhTQ== 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=iqI4x0+51VhqNNetnToWar6axmj8UB85q6HG9jhjHkE=; b=hym+JfceIRy5aKnwvjhhuFnJEosQX7oH6znRt+lwu6eDUxFkwrtUXdL4ZdUFtf9vVbwTesguKOaPFoypwp1egkXhu10gt1+5cq4kowcYbTKoWjLe23mcZoZ3IjfDq/1Wk1Oa1IxoVk96DA4uO0+tZixktWbIEytWGB7kzViag3O2Lq6rJOcjC0Aqam+5T3gO75SeufB3TlAsCjryNLh04SDATxebUUNnarPW/XTlmqVCN+3he28vHHUskH2WXVBY4ZAQrtTcjptO9ByNQAfFasSCVtpUJnPL4+X1ePQbr1FlcbDeswpRqo6ys2nmNZcAw65TXt5EbdLalzwZnVgVbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iqI4x0+51VhqNNetnToWar6axmj8UB85q6HG9jhjHkE=; b=ap46E3o/Yj3nAzzqL4wLdvGTfLFgWGAzdopvl4kB2DLuP/c/XRooVqiCMgBLactkkwqtB0vTbTD1SNaic5C0FHF/aREjFu96WbsOkEHe1NAbECgjlvzWlo0xkcinMNU5hpgwrijlH2O4weO3eHXzqTPIgSlTrcUCB+nBh3YWvFpz/6aEe8rkVZygnYeksPijmiPoIgtDw6NzggksWT//MyspNRYv4x3817IA8vvxpHIgsugLCeplrgaBpTvRzUV3PymvqpdWznEZcv4NAgq5Fj8SCtfVm6hvhIrPn40oFFhOloc3jZ6b7MiQkIeY28Zib3eH2UHBDlElrCJLvSxCbg== Received: from BY5PR04CA0020.namprd04.prod.outlook.com (2603:10b6:a03:1d0::30) by SA0PR12MB7478.namprd12.prod.outlook.com (2603:10b6:806:24b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:43 +0000 Received: from MWH0EPF000A6735.namprd04.prod.outlook.com (2603:10b6:a03:1d0:cafe::2e) by BY5PR04CA0020.outlook.office365.com (2603:10b6:a03:1d0::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.36 via Frontend Transport; Tue, 9 Apr 2024 19:09:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6735.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:42 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:15 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 9 Apr 2024 12:09:14 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:09:12 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Carolina Jubran , Tariq Toukan Subject: [PATCH net V2 10/12] net/mlx5e: RSS, Block XOR hash with over 128 channels Date: Tue, 9 Apr 2024 22:08:18 +0300 Message-ID: <20240409190820.227554-11-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6735:EE_|SA0PR12MB7478:EE_ X-MS-Office365-Filtering-Correlation-Id: 770e0e8b-1e43-4a4f-c224-08dc58c89ca2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wGJutfhQrZzDuJUL00/eVT5Ifr7WqOVwGDZlplCyR+iVEMrDQOHu73MqYmH8Oka7X+BH/7MNIio50eVIwNBRGhhLsdBAVcr0a472v+nAaPlg/RI9Qc+tZq2+h+21Jc2rnMO4lo15KCB847sQl4vvzbe9Fsn1eCjV3QCj24n0+FFa8m0ZdHYx64StHpO6Qkm+COdr+cAh8X3csdtK+EMgcRObW5/KXJL6t/fNK3tfxLC30U/lwbLjUMBwLUl19L8x+QmRpvedxRZivCqYJYsn10MP7C8UtSLTU04z2HVopHItkItrgyClhRA58BVDXBRq3PlIVNiF26ohb11G0rymrSJAchtbKtShGrtfpb98/FaqtwMsK5OJDeEk1565os/H1ILqQdeI1JbCQZcgOq/CESy1LX4+QUE/YMaKHnDstbSCJGiY1l2ovOxAUyuOoe0AmNVf9y8l9QWNxL3G9Fji1fi8XxARuz8NwoJ00KyrOfn3oy/5YXPwc0Mhq5bkeq4rWQMPVZhvvRbxfKoi5pjqx3fXqHIJyFOCX9UeM5+LILPbPPQGhgjkVshoGZZA9IbKdtl0PbLBeV/+fXQOrp/Vd2aFIWG+zWFOQGujiQpaWlNq932whkfQcdoUBBBAX052ZrE8C5yundd4/TKsCATCSKk9oEcxtSRQNC7+ZnfWKjLMoYPlL81hhCtMhvH3ujNWlR+Lrd4JILN2MnyPs3WSIEsvDteG/eKZr3J8O6hZJqOef9uR9egfm9U7U9wpZOZ7 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:42.2821 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 770e0e8b-1e43-4a4f-c224-08dc58c89ca2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6735.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7478 X-Patchwork-Delegate: kuba@kernel.org From: Carolina Jubran When supporting more than 128 channels, the RQT size is calculated by multiplying the number of channels by 2 and rounding up to the nearest power of 2. The index of the RQT is derived from the RSS hash calculations. If XOR8 is used as the RSS hash function, there are only 256 possible hash results, and therefore, only 256 indexes can be reached in the RQT. Block setting the RSS hash function to XOR when the number of channels exceeds 128. Fixes: 74a8dadac17e ("net/mlx5e: Preparations for supporting larger number of channels") Signed-off-by: Carolina Jubran Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/en/rqt.c | 7 +++++ .../net/ethernet/mellanox/mlx5/core/en/rqt.h | 1 + .../ethernet/mellanox/mlx5/core/en_ethtool.c | 28 +++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c index bcafb4bf9415..8d9a3b5ec973 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c @@ -179,6 +179,13 @@ u32 mlx5e_rqt_size(struct mlx5_core_dev *mdev, unsigned int num_channels) return min_t(u32, rqt_size, max_cap_rqt_size); } +#define MLX5E_MAX_RQT_SIZE_ALLOWED_WITH_XOR8_HASH 256 + +unsigned int mlx5e_rqt_max_num_channels_allowed_for_xor8(void) +{ + return MLX5E_MAX_RQT_SIZE_ALLOWED_WITH_XOR8_HASH / MLX5E_UNIFORM_SPREAD_RQT_FACTOR; +} + void mlx5e_rqt_destroy(struct mlx5e_rqt *rqt) { mlx5_core_destroy_rqt(rqt->mdev, rqt->rqtn); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.h b/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.h index e0bc30308c77..2f9e04a8418f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.h @@ -38,6 +38,7 @@ static inline u32 mlx5e_rqt_get_rqtn(struct mlx5e_rqt *rqt) } u32 mlx5e_rqt_size(struct mlx5_core_dev *mdev, unsigned int num_channels); +unsigned int mlx5e_rqt_max_num_channels_allowed_for_xor8(void); int mlx5e_rqt_redirect_direct(struct mlx5e_rqt *rqt, u32 rqn, u32 *vhca_id); int mlx5e_rqt_redirect_indir(struct mlx5e_rqt *rqt, u32 *rqns, u32 *vhca_ids, unsigned int num_rqns, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 93461b0c5703..8f101181648c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -451,6 +451,17 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, mutex_lock(&priv->state_lock); + if (mlx5e_rx_res_get_current_hash(priv->rx_res).hfunc == ETH_RSS_HASH_XOR) { + unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8(); + + if (count > xor8_max_channels) { + err = -EINVAL; + netdev_err(priv->netdev, "%s: Requested number of channels (%d) exceeds the maximum allowed by the XOR8 RSS hfunc (%d)\n", + __func__, count, xor8_max_channels); + goto out; + } + } + /* If RXFH is configured, changing the channels number is allowed only if * it does not require resizing the RSS table. This is because the previous * configuration may no longer be compatible with the new RSS table. @@ -1298,17 +1309,30 @@ int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh, struct mlx5e_priv *priv = netdev_priv(dev); u32 *rss_context = &rxfh->rss_context; u8 hfunc = rxfh->hfunc; + unsigned int count; int err; mutex_lock(&priv->state_lock); + + count = priv->channels.params.num_channels; + + if (hfunc == ETH_RSS_HASH_XOR) { + unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8(); + + if (count > xor8_max_channels) { + err = -EINVAL; + netdev_err(priv->netdev, "%s: Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n", + __func__, count, xor8_max_channels); + goto unlock; + } + } + if (*rss_context && rxfh->rss_delete) { err = mlx5e_rx_res_rss_destroy(priv->rx_res, *rss_context); goto unlock; } if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) { - unsigned int count = priv->channels.params.num_channels; - err = mlx5e_rx_res_rss_init(priv->rx_res, rss_context, count); if (err) goto unlock; From patchwork Tue Apr 9 19:08:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623090 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2048.outbound.protection.outlook.com [40.107.94.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F46E158D78 for ; Tue, 9 Apr 2024 19:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689793; cv=fail; b=mTnp1ih3cw8ip4ERf6vnad1BegMm9mTZNfwirtXPnDqZ3/tfSdtyRZydrTibpQqiolD+DlV/LtBY50cLucaD3QKMMjvKd4KFjaNusAEn4bw1uvfArTfz7MrKvV/F2yTuI9ja5LQAaSCrO0sjYAaVxceGrT+h6RDx7aBdVi7Q1qk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689793; c=relaxed/simple; bh=HDX9pjAok9XIXZ7Iq7ODMV4HM4NuIGFo4Jc8ZWN0aYs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AkGFI6JqU37iK1DjaCn0WONJSJjkOW71t+O8kT/nuh6S/jQi+8ikUupzpLNcPBAS4/F0DAfSrZ6rTAieO3lORKLU2R3vwLdTn3+jez8QOVtb3W4QIU5Ka0h883VoDTivKqA6BIMmjvEigv2jNLrnNq1ascjkybmP6hB12F3YtJM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Ctf7z0DH; arc=fail smtp.client-ip=40.107.94.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Ctf7z0DH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ixGiJXXO164t1HY/VS4Piq3est/RsV5Le+B5UIIwid4MufYbqHedHPNrBx9upp2n4oMqw6380pHPZtm3S64PGLC3wUCcz9u2FTFYb1ZXYjtNBDULz/sFJCYZFrloByHtLzmzvRtE888auDMPXs4tqsL19w7Dnk8Fty7JAhZ+BYPetQvJT7JkHXB5rQ9WLAJD1669CK936BTNDfVQXr1qhQ1HSb17mG3kPMh/+0Qw0P45vLWZpCfkQbTzcH+NNPRGGO7xz6VK561KVVCbWCzDo6twdM4f7GuG4RsMVEzppsAruVgp38fGWcaGrrI8zSt/AK3YPIw88xJz9ba1LskjdQ== 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=17sqJhLywAxXTX82fCizEnNWFW9nMykuUs/e0R+PUpA=; b=KP7gXZjNX6VJ1p2j4gWIMc6qQc9FgYQw/CalVYCxDgGgIQnLHpk2bKGq45kJwG0tbArK5kAP6xOyvolDdrsxfkW/IcGh9E914arqOcJjBLDDnLauxknVGCnQa2Hk8MPEd4064Xfg540th/GIu0wD83SvweFof95hTTJOvCFNs+Gh5JdEEU3rCg0YkFqJpNtI0A3pKGM38XxAND1M6W6eDJJR1nzIcwgJzlV0Xz8j+aR3C5LITmgcd0t+ujVPr4qASOx80z81Ll2l+6hONTcXEi52lr6F65ga9WG0Ed5ONL5IEQv4+egUkT5gfBEE6ga2CpuOXxfVOe7Tdq7WCO2vgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=17sqJhLywAxXTX82fCizEnNWFW9nMykuUs/e0R+PUpA=; b=Ctf7z0DHI1lOvj9Eb2HXUDEMskkg9yCCHChcCcVGPAuVBcSHNrktRdQLueZ1hyuecKHYBW7AqU2LO1mbuOCvreFiU9SzwooUVY7bjpCPK8WpAvEZd3Jw1Zu2AJnntnGFXojjg2irldmZhFcf+fzA+HrKcPq0sbpsmgmgSfCR0wcVQGWs/YCNI0WHym/SfOGP+BSo8Le2vnORD9YeUNTkYjhWUN9KPLVQgOwkSkzzmMBbfciaC+HXF2OYIqruEGstSj4kqSukJH3xM67oVnOC4Y9BCYD30I5qIk+YkXi7jnhCN1fwtPclAFoaOwQ7VLUwIeiqYtGw1vYXoIhgkPSfqg== Received: from SJ0PR03CA0208.namprd03.prod.outlook.com (2603:10b6:a03:2ef::33) by CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 19:09:46 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:a03:2ef:cafe::31) by SJ0PR03CA0208.outlook.office365.com (2603:10b6:a03:2ef::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37 via Frontend Transport; Tue, 9 Apr 2024 19:09:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:45 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:18 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:09:18 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:09:15 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Tariq Toukan , Dragos Tatulea Subject: [PATCH net V2 11/12] net/mlx5: Disallow SRIOV switchdev mode when in multi-PF netdev Date: Tue, 9 Apr 2024 22:08:19 +0300 Message-ID: <20240409190820.227554-12-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|CH3PR12MB9079:EE_ X-MS-Office365-Filtering-Correlation-Id: a3121653-54b3-4ad7-ee07-08dc58c89e98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZeNtn8RM9pds+SgTHwPp9+SEyPqIXlMF5ZJnqEaQ2AB+x8VyXBnaJGyWSnoTw++OmyQsGhUNoRQ5kV+WrXO1QNSKLchzu+Kex9IMpYCsjXkIlfc5d4x4LuZFj5favkpzgVHE1Mh7NGOvpOuHnMRw/RzP7QtbpJFxkpK/cjCKmU7EqqMqCc1NGoyLr9szvovDGdQFJGSv+KccD64d0lKm3cb21V3jcOP/oIjSal71dDvGBALzPm/x2y37z2bhQp1/GGu18mRds6pT0qp9EXSAzCpIis7NDjvLFXmPJ+/CDnJqbChJqUUMWM1AjV0LUoaEzwHPN3YNqLtzTcLJTmaEsuArVlkuyZprta7SxSqmiVvr10qfd+ITX6fcbQTYbhZYVuJU4MDK7ZjF61LDNmTI6dLj1XFLG4ad4IRkxlrdXkwJLtFyFp3kst66bWJAB23MC8koiiUIbE5Dq6wbRF52aQJkdeHVwPeVXnRUKyeW3x4gmp4DXL7J0UVfaUADF4FYAE8xtJSYToIDhwpisam30u7sk/Y+ejG8pNCD5XIFlAWiI9eHlLa1nXafbUqvUC7KrnDwKXyRe/ofLJdx6M1ThCmdJYOyoCS+KpTYe1iakdPNiHZSuoEKl0Qtk/unzrABq148vebkgAwWRVGrKp/V0TTWSdg5cLC26t9XyWOLK3Njpdjwq/IKXafWooG/PiKlxNcTeCj5fZj+D5jlA3KT75iVRnOoMaKPXoChZTyVfajPPUsSHVZQKYfrK7QEU4XF X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(1800799015)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:45.5731 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3121653-54b3-4ad7-ee07-08dc58c89e98 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9079 X-Patchwork-Delegate: kuba@kernel.org Adaptations need to be made for the auxiliary device management in the core driver level. Block this combination for now. Fixes: 678eb448055a ("net/mlx5: SD, Implement basic query and instantiation") Signed-off-by: Tariq Toukan Reviewed-by: Dragos Tatulea Reviewed-by: Gal Pressman --- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e3cce110e52f..1f60954c12f7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -43,6 +43,7 @@ #include "rdma.h" #include "en.h" #include "fs_core.h" +#include "lib/mlx5.h" #include "lib/devcom.h" #include "lib/eq.h" #include "lib/fs_chains.h" @@ -3711,6 +3712,12 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, if (esw_mode_from_devlink(mode, &mlx5_mode)) return -EINVAL; + if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV && mlx5_get_sd(esw->dev)) { + NL_SET_ERR_MSG_MOD(extack, + "Can't change E-Switch mode to switchdev when multi-PF netdev (Socket Direct) is configured."); + return -EPERM; + } + mlx5_lag_disable_change(esw->dev); err = mlx5_esw_try_lock(esw); if (err < 0) { From patchwork Tue Apr 9 19:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13623091 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74E11157E9A for ; Tue, 9 Apr 2024 19:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689794; cv=fail; b=V2MQRyvjLtN/xY12ALdOR0OW5Vvic4GJ0PqQOu200mUHYr2Ts01DZDNnPHlky8YKstkf5sKiFRESvXcwLjTtEKbNLw+7gz1tzuOuvFE+/TQQMHwhNHEzAmvll+a2Q0lUdUDI/R/bnlwWbsrup4YwFxFQQkvGHQjXJtcuqWNb2/I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712689794; c=relaxed/simple; bh=GhRlgmRJxig89GW80rrcYkis6bcEwu/Mb35WO+rt0fg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SoOwQkl62Fs11UeqqbuiUCteyUpVuVqet9x/sFpdWJd8ljrywTfV1yfqY1NHPknzBPjilpxmldkKzWAaLhSQBEQWQjc4Ag7hhZ2e5p/jr61fW/z2wY8l4JWXxac65btW6IqfOohIgJkN3RnyxWzQKPg66XxtGdU+pqnDGSMSEM8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=B+xN0Pts; arc=fail smtp.client-ip=40.107.94.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="B+xN0Pts" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nJkhRUj613uUY35M8DgWO4FXcTBUuaAmPsEFYURRP5zamIz/XCdo0nfiBKOfjRWKe46Z3BOzH7DUQ1Q41mR4M3G0EgEJWbz34IPOVQzSzIbOa2CVStBm0RaPLV4QtQpWgEvPd6CnlEB6hAM4OKthN+4Gtqt0DjTPEtfIA+fAt9no32s7j9N2jVXAnHWXgrllF+qxXCVWo3e8RfPncjiWBKyGggcjqWo9jgv3dPIafK85IA5MO3ahsPxA2s1sJZEJBBcOAgUV/vA/jEtWR02SwY7xU/tJdVYr1/qEwfOVpd3UroJUU+xOMIhvBY9FVczn+BcJU5BoNMGYsvl5WmGd2A== 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=R19iuGU9nC1tCNHpGbgimwQD4GddJ4M5V17Icb4JsbI=; b=C4EQ8VHJbBIxgKuu7lltectbPwDc0ZxiZo8SFGYlE9x8C1utLsYfCuvQ6zxHgbi3rtfD+LGlot9+UoUZ4kCLb2LY5swM4fCBvPbN35K8/VN52F7v1lZL72y1qOXvwwwJKWV/v0uIEYQ55THVVkBVRyeq+4rfkZYw4T29ufpbmCA6rJY+SVIzO7vc6ZjYzWM/tppXwljRqbT9Mama1G1332TEuKyFRgZS42oD7yAQsRECTstuN/oNbcQPCsRjW+88RmNzK7B5kuuiRhmOEh+RaWllAmebvNn3jXwGgioMKNAi8SRsqZk5PT3pxFgBHdNhey5q8S/8U8IZGFVecVaAHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R19iuGU9nC1tCNHpGbgimwQD4GddJ4M5V17Icb4JsbI=; b=B+xN0Pts7yWEZwGMKyrkEez+iS5BlpmMkSWePNy3WZneGdYj5Ra14TX3eA7ZPReBQC+DhiMrZESRrzSZiZtHCavwpR8lkFDsRVbPutfWyYrMCa7CjAhSVrYnJCeHfw+Clu/adiqy5Adfw8VTwmkupygAK4iVR8l+3cZNhepjmjcAHHjWnu/1eAv4yxmPBAx5G2YWz5wMP+WoC7S2gWq1H36La+pNR3w8/nQiIccrJDWKGJyQ4M0ZvPX7XTfAOKG3iMDLWkv/Y9gHknFaDkNGLnnIc3Sc0hBZK2+mSn2bnAh/SBarbLLSNhAlL/RACSXtHy1ZZ/gZ/CeW052VjcZCLQ== Received: from SJ0PR03CA0208.namprd03.prod.outlook.com (2603:10b6:a03:2ef::33) by SA1PR12MB6775.namprd12.prod.outlook.com (2603:10b6:806:25a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Tue, 9 Apr 2024 19:09:49 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:a03:2ef:cafe::4b) by SJ0PR03CA0208.outlook.office365.com (2603:10b6:a03:2ef::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37 via Frontend Transport; Tue, 9 Apr 2024 19:09:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 19:09:48 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Apr 2024 12:09:21 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1258.12; Tue, 9 Apr 2024 12:09:21 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 9 Apr 2024 12:09:18 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Tariq Toukan , Dan Carpenter Subject: [PATCH net V2 12/12] net/mlx5: SD, Handle possible devcom ERR_PTR Date: Tue, 9 Apr 2024 22:08:20 +0300 Message-ID: <20240409190820.227554-13-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409190820.227554-1-tariqt@nvidia.com> References: <20240409190820.227554-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|SA1PR12MB6775:EE_ X-MS-Office365-Filtering-Correlation-Id: 6098934f-41b6-4651-601f-08dc58c8a092 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vq+BQYet1zeE1CaNVt32bGYMt07W158KV601Ng+IRNtDQzYq34UYPV9A+2fNQzpN9FPMbHtg+wNh8giERheoEJyGwxG6Ih8VOb8LugjhYgVIpvhnTmnfImGY++wh8DO+2HrJlJZbP1QGMqyJ6qp4+IY+THQNj+fKtpOvY3diGDHTO8/pAYS2UMT8c22jz6jxrtWCoQhSCDUJW62qYLSZJAanKzHZhoPJkvyLOvwswxM+2mb3KxAesUhIWQCgpYNFZFiSLQQu2Gt3eGO0klwH7MBjhhMVuzjcBbwSc8tLRs7a5YyZKCzHU/aOh5YOmbXeNdwhzNyj7KW1Ch+9CeFn5Eqmo5LiyhrYpqvzA53D796KFicvw3+9jvHRo3C9/ZgXt9iByyIsLybxhtU7EkGYO0NEb4GnpHD/Fl+GVmAuZmGQk5qqrwRWfov+pqAcQXD75OYj54sRAbA1TD9GYxFdncxMqqgJQHQvIIK0ST/NLpi/jFhrMIDomIrTCui8Tum21DI0VVniQqVCTM/jbGKZmBhCkz3jQavrGVKJyZB54pvHH6IW4MPjyIZpaYvCM5oi6N2a8RpFzssuFdMXUXC/mFwxXFbohH7KvGiw0JgFF7J7mtYi+8D/zonGWEbpJQO86UCBCU5noMFGjsaHRgybGqx23hbAat7lgaRbmm2fEsw2TMyImMND4BrkEXLnFaMJLEFaGQNczIhR90g/Fu6Y9zqpYTlErBArGIcrgyOE+kgBSSENBrxBTltQXbksWg96 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(36860700004)(1800799015)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 19:09:48.8856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6098934f-41b6-4651-601f-08dc58c8a092 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6775 X-Patchwork-Delegate: kuba@kernel.org Check if devcom holds an error pointer and return immediately. This fixes Smatch static checker warning: drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c:221 sd_register() error: 'devcom' dereferencing possible ERR_PTR() Fixes: d3d057666090 ("net/mlx5: SD, Implement devcom communication and primary election") Reported-by: Dan Carpenter Link: https://lore.kernel.org/all/f09666c8-e604-41f6-958b-4cc55c73faf9@gmail.com/T/ Signed-off-by: Tariq Toukan Reviewed-by: Gal Pressman --- drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c index 5b28084e8a03..adbafed44ce7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c @@ -213,8 +213,8 @@ static int sd_register(struct mlx5_core_dev *dev) sd = mlx5_get_sd(dev); devcom = mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_SD_GROUP, sd->group_id, NULL, dev); - if (!devcom) - return -ENOMEM; + if (IS_ERR_OR_NULL(devcom)) + return devcom ? PTR_ERR(devcom) : -ENOMEM; sd->devcom = devcom;