From patchwork Mon Feb 19 18:23:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13562977 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 16443481DB for ; Mon, 19 Feb 2024 18:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367010; cv=none; b=I79ZfmLY1RPOS9qXkW2BG/Qd5Xusnucb5Gk3ABycO0POC7cXdc/Aolm8l395JV7m2Kqank2a/7Tpl4rZa1QkKoFYfpB8n7mJw8CsEYgOG5xHvaIQ0os97DvLGX57GseW40WZ+iKEK9A2FJl4UMS5roB5uKtnP4rXg672tVSvhxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367010; c=relaxed/simple; bh=I/m+hRWubgJHuRnOQRHARHrNdhPJb97QzdgjnXP0gEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Li5tGBf3DP6pPOsEMxGhG1YK+j6OmoHJDH5fRR2VUYDH6iQJMPGEsxT8LXFuihagDz5CZTVX/R+4Onnp5E7KK3EBFBeQ4vtRC6VPVrtoxQkKaI0W+j+7BG4JXxd7n/Vs1dY5ZfxzZAF5A7c1Q+uKtR0ezD+lVg7HLNMPdGm21fg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XpN5tbsm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XpN5tbsm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C714C43394; Mon, 19 Feb 2024 18:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708367009; bh=I/m+hRWubgJHuRnOQRHARHrNdhPJb97QzdgjnXP0gEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XpN5tbsm0S0sOX/roEDhoxIgSskp/IUu9+Fx9nK98oZFgEMmFI53sivQWELWQpHQq a7L2Ow1YW5kCvLqVrPgfXRxfrC6TaMD+4kqLqkNMZh5Qxlu4oJjS7k4jvBFAP65+Il Yt9GdLVWN3O4bHNivQspEB8PLIAUfTDk5SUo//OZtAGO1tdBJ8cCDepGMuuOb9IsbH IEVbKE8NkvLvfOkYpQ6WjEJsHBEcU1plA+gFQRYlySlVENUtcrrtCHsgytz22yD32k zomVzxGXxo2GSRA8L9ZRMmzkB1VMFTX1tW/8QYwPlXSugk6lWefXyTP/42HDjUN+zI w28OcOIGTUxxA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky , Gavin Li , Jiri Pirko Subject: [net 01/10] Revert "net/mlx5: Block entering switchdev mode with ns inconsistency" Date: Mon, 19 Feb 2024 10:23:11 -0800 Message-ID: <20240219182320.8914-2-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Gavin Li This reverts commit 662404b24a4c4d839839ed25e3097571f5938b9b. The revert is required due to the suspicion it is not good for anything and cause crash. Fixes: 662404b24a4c ("net/mlx5e: Block entering switchdev mode with ns inconsistency") Signed-off-by: Gavin Li Reviewed-by: Jiri Pirko Signed-off-by: Saeed Mahameed --- .../mellanox/mlx5/core/eswitch_offloads.c | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index b0455134c98e..14b3bd3c5e2f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -3658,22 +3658,6 @@ static int esw_inline_mode_to_devlink(u8 mlx5_mode, u8 *mode) return 0; } -static bool esw_offloads_devlink_ns_eq_netdev_ns(struct devlink *devlink) -{ - struct mlx5_core_dev *dev = devlink_priv(devlink); - struct net *devl_net, *netdev_net; - bool ret = false; - - mutex_lock(&dev->mlx5e_res.uplink_netdev_lock); - if (dev->mlx5e_res.uplink_netdev) { - netdev_net = dev_net(dev->mlx5e_res.uplink_netdev); - devl_net = devlink_net(devlink); - ret = net_eq(devl_net, netdev_net); - } - mutex_unlock(&dev->mlx5e_res.uplink_netdev_lock); - return ret; -} - int mlx5_eswitch_block_mode(struct mlx5_core_dev *dev) { struct mlx5_eswitch *esw = dev->priv.eswitch; @@ -3718,13 +3702,6 @@ 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 && - !esw_offloads_devlink_ns_eq_netdev_ns(devlink)) { - NL_SET_ERR_MSG_MOD(extack, - "Can't change E-Switch mode to switchdev when netdev net namespace has diverged from the devlink's."); - return -EPERM; - } - mlx5_lag_disable_change(esw->dev); err = mlx5_esw_try_lock(esw); if (err < 0) { From patchwork Mon Feb 19 18:23:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13562978 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BBDD9481DB for ; Mon, 19 Feb 2024 18:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367011; cv=none; b=riwG+eI9uGcBCgTHRvilIXMpWhwyH6rjLw2yr+MdSuoqnimwuV72ivDlC8mBPVg8Hoa/WezUmycABMNPzA0wd1vtctplPf3Mq/pD1kq7FyFTtM0FTtLXUXCOeDAv7K7fla9w9xqsRuZ0jWF25IOGr5/nZ3JqrDvDISdY2BcmnLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367011; c=relaxed/simple; bh=ui5Q7u4Cev3lNjw3eM2c0399K256i235lRxtY9Lnmu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uka+4nyN9/t7ZdZDRGXG+cLKT8HEEsjV/Z1+9uQr97Yxt3SNTVWAwm4zF9q6jUivI2XUoHLnJzc9OihlnVFxpJwpMGUALoF4FGamnjYtZKoeWBtOA5zWnfp/7CqflZa3LMlHxnG6j4oqLrJih5KM5feOOmXd/NXmRm+Qkabrbbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SO7v6rc4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SO7v6rc4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 554ACC43390; Mon, 19 Feb 2024 18:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708367011; bh=ui5Q7u4Cev3lNjw3eM2c0399K256i235lRxtY9Lnmu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SO7v6rc42GXgkoMkku3BrcrU/kAUxgxUe4JDo3AblSr2nB3vorAA5B54LMsHZ7a0K uog5yjNemFn66epOFZ6EXq6H7ugdN2lYQrrbhPeW6zwjaNBqGO+Nu2ObAF1lBy9MgW BmVYayYgiczETAOhrhaPhQGQBp127Q++X9Y5+1zaDUSSwnSWimX+qipCkhLgpIU/3v lDvAXscq+z+jct6sWzpT4CH/MYAZ85AL6WE8KCtzRz4qj/xwPgdd6mJ79Me6Z78c2m kIJeolSsVI+fdT4h686PvO6Z1I6v+A20sUx2D+b0Ef6JAmR2mGo4z2mtroP3UcNwZO DtK3IEo6fK2TA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky Subject: [net 02/10] Revert "net/mlx5e: Check the number of elements before walk TC rhashtable" Date: Mon, 19 Feb 2024 10:23:12 -0800 Message-ID: <20240219182320.8914-3-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Saeed Mahameed This reverts commit 4e25b661f484df54b6751b65f9ea2434a3b67539. This Commit was mistakenly applied by pulling the wrong tag, remove it. Fixes: 4e25b661f484 ("net/mlx5e: Check the number of elements before walk TC rhashtable") Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c index 190f10aba170..5a0047bdcb51 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c @@ -152,7 +152,7 @@ void mlx5_esw_ipsec_restore_dest_uplink(struct mlx5_core_dev *mdev) xa_for_each(&esw->offloads.vport_reps, i, rep) { rpriv = rep->rep_data[REP_ETH].priv; - if (!rpriv || !rpriv->netdev || !atomic_read(&rpriv->tc_ht.nelems)) + if (!rpriv || !rpriv->netdev) continue; rhashtable_walk_enter(&rpriv->tc_ht, &iter); From patchwork Mon Feb 19 18:23:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13562979 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A2586481DB for ; Mon, 19 Feb 2024 18:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367013; cv=none; b=Q3GExCZKoUctY8IDdof2e7TwbXc82Vb2FV8Gl7rrQSnN0b40WiThxB5U114u/XUQdq3XuIsHxeJT2aNqiPjZt5vU++KvELm3PHNIb5QL7WrShq413t0bYWRjv7/C8Sl915kW5FCKnI8lWsPq6MxNt/XwFJ6Pye5TUlFNpGouqL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367013; c=relaxed/simple; bh=Ga0TZcUYanXDP+17fFxdQ3JQJMZkoYNKWXAdeyxEYlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tT2Cfo2BOmvwVVM1ibzzwPEOBiQgRGftc5KSASlBYrmDaTJdHnuPOiAYCEVCckuMQzxKvIrPpljv4X0xHjAGYGpf4fnkvt9wF1p13g3e2ckDtb4m58kmXJv3GXWdwtqny6OT01u+5QOXZA/e2rHWLRGeg7ZODOuhUVlL0bLRBkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SNZUqK5o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SNZUqK5o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AF2AC43399; Mon, 19 Feb 2024 18:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708367013; bh=Ga0TZcUYanXDP+17fFxdQ3JQJMZkoYNKWXAdeyxEYlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNZUqK5oZqpJLQlNDNAgaioQRuTgOQ2lZH9tLaRd3zr+gjfY822E0yyA9auQZY0cW xuW3P2Cp+Kxu6jrOkyC7dlNOk0Ck6nkqsjG0zLjEe1BK4JX2Y715xKe8G8/oovjBfp EhQyxt4SSMEnaT1T338uvOQ8vmByhwDLqKTmDBgUAfw+td4xhRinb8VIky5rXBe2bZ H1/Y6gVPgsJYGgA8MeRtsxaWhO1/xonXDiXP8vhFV/oWrXipmPJ9+BCDm375lg5Et/ q/rmqraXG3HqVmTtb+Qydse0cBv72N8/5ucFO4Ml5Q7JEKAUS+DEOjhz91G6lC71gs sONJmPtgSIYxw== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky , Jianbo Liu , Rahul Rameshbabu Subject: [net 03/10] net/mlx5: E-switch, Change flow rule destination checking Date: Mon, 19 Feb 2024 10:23:13 -0800 Message-ID: <20240219182320.8914-4-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jianbo Liu The checking in the cited commit is not accurate. In the common case, VF destination is internal, and uplink destination is external. However, uplink destination with packet reformat is considered as internal because firmware uses LB+hairpin to support it. Update the checking so header rewrite rules with both internal and external destinations are not allowed. Fixes: e0e22d59b47a ("net/mlx5: E-switch, Add checking for flow rule destinations") Signed-off-by: Jianbo Liu Reviewed-by: Rahul Rameshbabu Signed-off-by: Saeed Mahameed --- .../mellanox/mlx5/core/eswitch_offloads.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index 14b3bd3c5e2f..baaae628b0a0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -535,21 +535,26 @@ esw_src_port_rewrite_supported(struct mlx5_eswitch *esw) } static bool -esw_dests_to_vf_pf_vports(struct mlx5_flow_destination *dests, int max_dest) +esw_dests_to_int_external(struct mlx5_flow_destination *dests, int max_dest) { - bool vf_dest = false, pf_dest = false; + bool internal_dest = false, external_dest = false; int i; for (i = 0; i < max_dest; i++) { - if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT) + if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT && + dests[i].type != MLX5_FLOW_DESTINATION_TYPE_UPLINK) continue; - if (dests[i].vport.num == MLX5_VPORT_UPLINK) - pf_dest = true; + /* Uplink dest is external, but considered as internal + * if there is reformat because firmware uses LB+hairpin to support it. + */ + if (dests[i].vport.num == MLX5_VPORT_UPLINK && + !(dests[i].vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID)) + external_dest = true; else - vf_dest = true; + internal_dest = true; - if (vf_dest && pf_dest) + if (internal_dest && external_dest) return true; } @@ -695,9 +700,9 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, /* Header rewrite with combined wire+loopback in FDB is not allowed */ if ((flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) && - esw_dests_to_vf_pf_vports(dest, i)) { + esw_dests_to_int_external(dest, i)) { esw_warn(esw->dev, - "FDB: Header rewrite with forwarding to both PF and VF is not allowed\n"); + "FDB: Header rewrite with forwarding to both internal and external dests is not allowed\n"); rule = ERR_PTR(-EINVAL); goto err_esw_get; } From patchwork Mon Feb 19 18:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13562980 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3C99D481DB for ; Mon, 19 Feb 2024 18:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367015; cv=none; b=YegXFpH49ecKHttOFleNxX+DHqT+jnRglpbfMPBKJqtAk8tk9d1cBT3IEUgjs+Ncm9R447gnDc0iLo2YzA/9BI3NaQ/n/DugcYV6vpZgFiNf0SynazqphFZSZvVjZtB/VITtlgqTKYvK+2gBRbA6LBl1e5ijOnRdy9ypv4a6Mcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367015; c=relaxed/simple; bh=ebSFEy8F0Gke9fNlkcrSL4FNIak5iY+E245RQtTKbNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdWNcoDOdnV+p6hQfJDWMTu12bmbQW+1QUgbgUM82g7gs8+G9kVZvkliZZRa6ddYj3fhSikhYDXBH8PPQTCe5lf8c03VPG5DqKKjYUvzIYYoWTMoIGkQjN5AC4EJLGYfScBab1Z7u9g/WUQZf1ePON7Ws8bCUAzwu1U/52jTehY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n/Sck9Zx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n/Sck9Zx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A38C0C43390; Mon, 19 Feb 2024 18:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708367014; bh=ebSFEy8F0Gke9fNlkcrSL4FNIak5iY+E245RQtTKbNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/Sck9ZxSy2rB19845C2PUse9AbIx5yTS2syogAUnnafrwZ8B2eOxZTQhXDxh8KwW dzsyxjzN9Su2lRoHM1J85WVGCYMoynsO+OFObeGURyEzW6TikteYkiMF6BpI7/8Gym 8kop7aUIQN5detxO4wPZekDLr2cCsPjaMXRvI9HZhyMgv/BmUiFLFeKZkfZmXeHqPa dWIXryXE++CgrSr61XdM2hpRg6p42+R+DWMuG2pd1mKtT4BSoy59WgTIOvrQqnr4L+ tigcty/lkIBXhiZakwefavEGR0pYIuMWujskGcMtsTXDFAPiiteVWSOGZi8tL7dX87 u9xxjlHfA/5nQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky , Aya Levin , Moshe Shemesh Subject: [net 04/10] net/mlx5: Fix fw reporter diagnose output Date: Mon, 19 Feb 2024 10:23:14 -0800 Message-ID: <20240219182320.8914-5-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Aya Levin Restore fw reporter diagnose to print the syndrome even if it is zero. Following the cited commit, in this case (syndrome == 0) command returns no output at all. This fix restores command output in case syndrome is cleared: $ devlink health diagnose pci/0000:82:00.0 reporter fw Syndrome: 0 Fixes: d17f98bf7cc9 ("net/mlx5: devlink health: use retained error fmsg API") Signed-off-by: Aya Levin Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 8ff6dc9bc803..b5c709bba155 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -452,10 +452,10 @@ mlx5_fw_reporter_diagnose(struct devlink_health_reporter *reporter, struct health_buffer __iomem *h = health->health; u8 synd = ioread8(&h->synd); + devlink_fmsg_u8_pair_put(fmsg, "Syndrome", synd); if (!synd) return 0; - devlink_fmsg_u8_pair_put(fmsg, "Syndrome", synd); devlink_fmsg_string_pair_put(fmsg, "Description", hsynd_str(synd)); return 0; From patchwork Mon Feb 19 18:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13562981 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 95F48481DB for ; Mon, 19 Feb 2024 18:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367016; cv=none; b=JJgxNaeaibMv600Pz7wm2vReX77C1Pu9/ZfdcymlRccx0CmiFu13haC5A330eIYfD7V3gtLQuSpt+tamLc+5mtJX5lGExR1DUGFcCWuIoRW+u59XTTermOM5Cb4sGt5cr0yzJIphgQV7aBUlre1cNKp3i3VxFHP2ZSrsnoU3czg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367016; c=relaxed/simple; bh=tmbTATcDT0i2NkUxnzvuGXwz8V9zDQ3GeIpMhNYzxjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bqtUbW5MEamsdAUPweS6qOLSUvh/e2duW1FU2IOYwilGeWJO+3t2GY8KCXLCf3LUjKXy689EQ8yaSuORqlxg5JxxBGoByCLJaaXeW/afGzJsSWC5wa8omvHbynAd3XT8RQEV1vXPlGZsLkZdGBDDHgah8ApGJeewJ1NlSvGmLh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LBi1wreS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LBi1wreS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AE98C43390; Mon, 19 Feb 2024 18:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708367016; bh=tmbTATcDT0i2NkUxnzvuGXwz8V9zDQ3GeIpMhNYzxjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBi1wreSwn0JEh1ulZrfbAL8PrBrPBAm/dXNRnK3X7prqtNx77T5boLEX0zbiX/8J HnEWpl/zE8u4PvLxn+hPnJ+Qze8PL4PzT4FKJpSdBqcS+ahJ/WZIcMS2LRH9QpgodU svUky1ETB5xxHb0CEeeDIwBEZmb01OYH9Gy/ZQhVukKt5gq2IjH13QoWrOjsDQl1Hg 1K4N1MG4lYwueQd1dbgujtrFnFRBk/jf9cG7rSMryYBrYV9ZCJZ4YRUI66rPDaFpRN 090FFvSf/57GRHsFM0rY5Zn+5fAdTgGUMSHAzjPzoXtVJgI6jnP0+m3q4drV18BwJe rWUPR0QFF1JCQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky , Moshe Shemesh , Aya Levin Subject: [net 05/10] net/mlx5: Check capability for fw_reset Date: Mon, 19 Feb 2024 10:23:15 -0800 Message-ID: <20240219182320.8914-6-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Moshe Shemesh Functions which can't access MFRL (Management Firmware Reset Level) register, have no use of fw_reset structures or events. Remove fw_reset structures allocation and registration for fw reset events notifications for these functions. Having the devlink param enable_remote_dev_reset on functions that don't have this capability is misleading as these functions are not allowed to influence the reset flow. Hence, this patch removes this parameter for such functions. In addition, return not supported on devlink reload action fw_activate for these functions. Fixes: 38b9f903f22b ("net/mlx5: Handle sync reset request event") Signed-off-by: Moshe Shemesh Reviewed-by: Aya Levin Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/devlink.c | 6 +++++ .../ethernet/mellanox/mlx5/core/fw_reset.c | 22 +++++++++++++++++-- include/linux/mlx5/mlx5_ifc.h | 4 +++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 3e064234f6fe..98d4306929f3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -157,6 +157,12 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, return -EOPNOTSUPP; } + if (action == DEVLINK_RELOAD_ACTION_FW_ACTIVATE && + !dev->priv.fw_reset) { + NL_SET_ERR_MSG_MOD(extack, "FW activate is unsupported for this function"); + return -EOPNOTSUPP; + } + if (mlx5_core_is_pf(dev) && pci_num_vf(pdev)) NL_SET_ERR_MSG_MOD(extack, "reload while VFs are present is unfavorable"); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c index f27eab6e4929..2911aa34a5be 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -703,19 +703,30 @@ void mlx5_fw_reset_events_start(struct mlx5_core_dev *dev) { struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; + if (!fw_reset) + return; + MLX5_NB_INIT(&fw_reset->nb, fw_reset_event_notifier, GENERAL_EVENT); mlx5_eq_notifier_register(dev, &fw_reset->nb); } void mlx5_fw_reset_events_stop(struct mlx5_core_dev *dev) { - mlx5_eq_notifier_unregister(dev, &dev->priv.fw_reset->nb); + struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; + + if (!fw_reset) + return; + + mlx5_eq_notifier_unregister(dev, &fw_reset->nb); } void mlx5_drain_fw_reset(struct mlx5_core_dev *dev) { struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; + if (!fw_reset) + return; + set_bit(MLX5_FW_RESET_FLAGS_DROP_NEW_REQUESTS, &fw_reset->reset_flags); cancel_work_sync(&fw_reset->fw_live_patch_work); cancel_work_sync(&fw_reset->reset_request_work); @@ -733,9 +744,13 @@ static const struct devlink_param mlx5_fw_reset_devlink_params[] = { int mlx5_fw_reset_init(struct mlx5_core_dev *dev) { - struct mlx5_fw_reset *fw_reset = kzalloc(sizeof(*fw_reset), GFP_KERNEL); + struct mlx5_fw_reset *fw_reset; int err; + if (!MLX5_CAP_MCAM_REG(dev, mfrl)) + return 0; + + fw_reset = kzalloc(sizeof(*fw_reset), GFP_KERNEL); if (!fw_reset) return -ENOMEM; fw_reset->wq = create_singlethread_workqueue("mlx5_fw_reset_events"); @@ -771,6 +786,9 @@ void mlx5_fw_reset_cleanup(struct mlx5_core_dev *dev) { struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; + if (!fw_reset) + return; + devl_params_unregister(priv_to_devlink(dev), mlx5_fw_reset_devlink_params, ARRAY_SIZE(mlx5_fw_reset_devlink_params)); diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index c726f90ab752..b113fffd5e57 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -10261,7 +10261,9 @@ struct mlx5_ifc_mcam_access_reg_bits { u8 regs_63_to_46[0x12]; u8 mrtc[0x1]; - u8 regs_44_to_32[0xd]; + u8 regs_44_to_41[0x4]; + u8 mfrl[0x1]; + u8 regs_39_to_32[0x8]; u8 regs_31_to_10[0x16]; u8 mtmp[0x1]; From patchwork Tue Feb 20 03:29:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13563344 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 288C55914E for ; Tue, 20 Feb 2024 03:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399790; cv=none; b=J6yBa5e+uFQ2F9gUPsi/POJ729WoM5r7FeHeo6uCz/AEgWW/TqoYq7zkMHApF/KNZIjQNMveiDbgaRsZDmTnIo9KJcag5dC0ubhHNvf2v4LuLtj2HmrcigfzTb1dL7r2rPI0QCo1115SVkasIr4rbU7jTYWpEh3fNT5WsxB/HfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399790; c=relaxed/simple; bh=i4MCCE6c8DaZ4TTe6eX3DR6H22mywFtjOSSJIEYPFtU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRSjZjvZaJcBP+fP733XRUVAS2is+FH4zhNeqBbESxQbiV+RNYFS94ixTol/ceKnW4806locA5L/6HIkjSEDcxQtC1xP5wYe9ojQB/009x7rAZIgmYIUcPEuxIz+rt3JV2RqWJMKXw2sZKoMPpzLEF/pXIKp4OoIYAsTft7bjRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S7uUNvCc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S7uUNvCc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EA71C433C7; Tue, 20 Feb 2024 03:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708399789; bh=i4MCCE6c8DaZ4TTe6eX3DR6H22mywFtjOSSJIEYPFtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7uUNvCcd0fs2ta0+BU46wRehhNMhXJpSbAKOABGAqdg3R3fkGv3Gh63kTdjZUtZm PNzwmzpEKbODID5BPauf5YPdbnNtsr/vFWK6LhwFGAi1rHmMUpL+2Y5woHnGMImXMT zA3DEWBFvmABb69wehgZaUzuEWcam/RAJtC6R2aIu5w9YyIfDkNI3WnIbLvoF2ViIE 6OALrCOMpgcaJhb9fQvjMa3J2uOgWOLXkten6dlIRWMPbLXhAnpVjmSQ0Cotvn1pjp fEDtOAc9SqeHCctPysMb5xiE5EUA0hQaRfxxnlvdaGd/psXzv4WtsYI169fhF1W/li gWqfX8RLFhfIQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky Subject: [net 06/10] net/mlx5e: Change the warning when ignore_flow_level is not supported Date: Mon, 19 Feb 2024 19:29:44 -0800 Message-ID: <20240220032948.35305-1-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jianbo Liu Downgrade the print from mlx5_core_warn() to mlx5_core_dbg(), as it is just a statement of fact that firmware doesn't support ignore flow level. And change the wording to "firmware flow level support is missing", to make it more accurate. Fixes: ae2ee3be99a8 ("net/mlx5: CT: Remove warning of ignore_flow_level support for VFs") Signed-off-by: Jianbo Liu Suggested-by: Elliott, Robert (Servers) Reviewed-by: Roi Dayan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c index 86bf007fd05b..b500cc2c9689 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c @@ -37,7 +37,7 @@ mlx5e_tc_post_act_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains, if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev, ignore_flow_level, table_type)) { if (priv->mdev->coredev_type == MLX5_COREDEV_PF) - mlx5_core_warn(priv->mdev, "firmware level support is missing\n"); + mlx5_core_dbg(priv->mdev, "firmware flow level support is missing\n"); err = -EOPNOTSUPP; goto err_check; } From patchwork Tue Feb 20 03:29:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13563345 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E82E147A4C for ; Tue, 20 Feb 2024 03:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399791; cv=none; b=EApHOXcNbQ0DwwBFM07u4ImbEsTYYz1J/nHKgRetmEdLUtEZfo8fIW6uXdA1/UcIF9FcNZa0KljFkKE8w8DxlKmSgzuKsed/TBhO1y+bRzkvKcx3rNmFOgCdGhzDTXs6ep0DBoz9QPU0eeDvgR8XAn/yr7DcQhfRVxh/Y/aUCEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399791; c=relaxed/simple; bh=OmKUZeb07Wa4YX2Ho6nBTEI8MDn4UwUvKgWM9MWw8/M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OLx1O13XINdxfYO9oPoEf1nOq2n+3NaHTFpQ6qq0gX6kTuOFxnO8cCS0mXeYELDxIfzuTXtfEN4UlVM01coMqLgXLyhnb2ZuQbWigom+dKdD/MpHkK6AHQpIu2odIrDrqP5OwtUNrwzjrcV3xhcufI2ECfa6bIkSdpTZNTHaHIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NJwbnf/u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NJwbnf/u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A649AC433F1; Tue, 20 Feb 2024 03:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708399790; bh=OmKUZeb07Wa4YX2Ho6nBTEI8MDn4UwUvKgWM9MWw8/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NJwbnf/uga6GZHqkXM2IuSY36cUJmwPq2ltBqqWklarbVxgElzi+C6WAG6iQr7LR3 jPx77F7X1diN95BJnEbUa2edVWwb3ZMpQwtMSe1w3cYz/OWsPO5zMIDvfmdWJLGGp1 qhG3fFA3pnuXOt9dxwkY+CnPUu6A4o20mo6Qm0UbHjc+H31vd1/diYDMfH4WJ5Ckq8 KPl9d3I6w9pvqLusfPVnVgpWs05LBLQudhQdQCT8bUPLhV4CaNZL9BEtjt0WSUcstG 5BH+cf0JlKL3tuP13j012DjsRa8zZ3LKPnFFNrR9RxuXl19gryv13DFXTTbYcvfP/m w+vYqNjFIyBXQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky Subject: [net 07/10] net/mlx5e: Fix MACsec state loss upon state update in offload path Date: Mon, 19 Feb 2024 19:29:45 -0800 Message-ID: <20240220032948.35305-2-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Emeel Hakim The packet number attribute of the SA is incremented by the device rather than the software stack when enabling hardware offload. Because the packet number attribute is managed by the hardware, the software has no insight into the value of the packet number attribute actually written by the device. Previously when MACsec offload was enabled, the hardware object for handling the offload was destroyed when the SA was disabled. Re-enabling the SA would lead to a new hardware object being instantiated. This new hardware object would not have any recollection of the correct packet number for the SA. Instead, destroy the flow steering rule when deactivating the SA and recreate it upon reactivation, preserving the original hardware object. Fixes: 8ff0ac5be144 ("net/mlx5: Add MACsec offload Tx command support") Signed-off-by: Emeel Hakim Signed-off-by: Rahul Rameshbabu Reviewed-by: Gal Pressman Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../mellanox/mlx5/core/en_accel/macsec.c | 82 ++++++++++++------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c index d4ebd8743114..b2cabd6ab86c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -310,9 +310,9 @@ static void mlx5e_macsec_destroy_object(struct mlx5_core_dev *mdev, u32 macsec_o mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out)); } -static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec, - struct mlx5e_macsec_sa *sa, - bool is_tx, struct net_device *netdev, u32 fs_id) +static void mlx5e_macsec_cleanup_sa_fs(struct mlx5e_macsec *macsec, + struct mlx5e_macsec_sa *sa, bool is_tx, + struct net_device *netdev, u32 fs_id) { int action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT : MLX5_ACCEL_MACSEC_ACTION_DECRYPT; @@ -322,20 +322,49 @@ static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec, mlx5_macsec_fs_del_rule(macsec->mdev->macsec_fs, sa->macsec_rule, action, netdev, fs_id); - mlx5e_macsec_destroy_object(macsec->mdev, sa->macsec_obj_id); sa->macsec_rule = NULL; } +static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec, + struct mlx5e_macsec_sa *sa, bool is_tx, + struct net_device *netdev, u32 fs_id) +{ + mlx5e_macsec_cleanup_sa_fs(macsec, sa, is_tx, netdev, fs_id); + mlx5e_macsec_destroy_object(macsec->mdev, sa->macsec_obj_id); +} + +static int mlx5e_macsec_init_sa_fs(struct macsec_context *ctx, + struct mlx5e_macsec_sa *sa, bool encrypt, + bool is_tx, u32 *fs_id) +{ + struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev); + struct mlx5_macsec_fs *macsec_fs = priv->mdev->macsec_fs; + struct mlx5_macsec_rule_attrs rule_attrs; + union mlx5_macsec_rule *macsec_rule; + + rule_attrs.macsec_obj_id = sa->macsec_obj_id; + rule_attrs.sci = sa->sci; + rule_attrs.assoc_num = sa->assoc_num; + rule_attrs.action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT : + MLX5_ACCEL_MACSEC_ACTION_DECRYPT; + + macsec_rule = mlx5_macsec_fs_add_rule(macsec_fs, ctx, &rule_attrs, fs_id); + if (!macsec_rule) + return -ENOMEM; + + sa->macsec_rule = macsec_rule; + + return 0; +} + static int mlx5e_macsec_init_sa(struct macsec_context *ctx, struct mlx5e_macsec_sa *sa, bool encrypt, bool is_tx, u32 *fs_id) { struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev); struct mlx5e_macsec *macsec = priv->macsec; - struct mlx5_macsec_rule_attrs rule_attrs; struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_macsec_obj_attrs obj_attrs; - union mlx5_macsec_rule *macsec_rule; int err; obj_attrs.next_pn = sa->next_pn; @@ -357,20 +386,12 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx, if (err) return err; - rule_attrs.macsec_obj_id = sa->macsec_obj_id; - rule_attrs.sci = sa->sci; - rule_attrs.assoc_num = sa->assoc_num; - rule_attrs.action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT : - MLX5_ACCEL_MACSEC_ACTION_DECRYPT; - - macsec_rule = mlx5_macsec_fs_add_rule(mdev->macsec_fs, ctx, &rule_attrs, fs_id); - if (!macsec_rule) { - err = -ENOMEM; - goto destroy_macsec_object; + if (sa->active) { + err = mlx5e_macsec_init_sa_fs(ctx, sa, encrypt, is_tx, fs_id); + if (err) + goto destroy_macsec_object; } - sa->macsec_rule = macsec_rule; - return 0; destroy_macsec_object: @@ -526,9 +547,7 @@ static int mlx5e_macsec_add_txsa(struct macsec_context *ctx) goto destroy_sa; macsec_device->tx_sa[assoc_num] = tx_sa; - if (!secy->operational || - assoc_num != tx_sc->encoding_sa || - !tx_sa->active) + if (!secy->operational) goto out; err = mlx5e_macsec_init_sa(ctx, tx_sa, tx_sc->encrypt, true, NULL); @@ -595,7 +614,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx) goto out; if (ctx_tx_sa->active) { - err = mlx5e_macsec_init_sa(ctx, tx_sa, tx_sc->encrypt, true, NULL); + err = mlx5e_macsec_init_sa_fs(ctx, tx_sa, tx_sc->encrypt, true, NULL); if (err) goto out; } else { @@ -604,7 +623,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx) goto out; } - mlx5e_macsec_cleanup_sa(macsec, tx_sa, true, ctx->secy->netdev, 0); + mlx5e_macsec_cleanup_sa_fs(macsec, tx_sa, true, ctx->secy->netdev, 0); } out: mutex_unlock(&macsec->lock); @@ -1030,8 +1049,9 @@ static int mlx5e_macsec_del_rxsa(struct macsec_context *ctx) goto out; } - mlx5e_macsec_cleanup_sa(macsec, rx_sa, false, ctx->secy->netdev, - rx_sc->sc_xarray_element->fs_id); + if (rx_sa->active) + mlx5e_macsec_cleanup_sa(macsec, rx_sa, false, ctx->secy->netdev, + rx_sc->sc_xarray_element->fs_id); mlx5_destroy_encryption_key(macsec->mdev, rx_sa->enc_key_id); kfree(rx_sa); rx_sc->rx_sa[assoc_num] = NULL; @@ -1112,8 +1132,8 @@ static int macsec_upd_secy_hw_address(struct macsec_context *ctx, if (!rx_sa || !rx_sa->macsec_rule) continue; - mlx5e_macsec_cleanup_sa(macsec, rx_sa, false, ctx->secy->netdev, - rx_sc->sc_xarray_element->fs_id); + mlx5e_macsec_cleanup_sa_fs(macsec, rx_sa, false, ctx->secy->netdev, + rx_sc->sc_xarray_element->fs_id); } } @@ -1124,8 +1144,8 @@ static int macsec_upd_secy_hw_address(struct macsec_context *ctx, continue; if (rx_sa->active) { - err = mlx5e_macsec_init_sa(ctx, rx_sa, true, false, - &rx_sc->sc_xarray_element->fs_id); + err = mlx5e_macsec_init_sa_fs(ctx, rx_sa, true, false, + &rx_sc->sc_xarray_element->fs_id); if (err) goto out; } @@ -1178,7 +1198,7 @@ static int mlx5e_macsec_upd_secy(struct macsec_context *ctx) if (!tx_sa) continue; - mlx5e_macsec_cleanup_sa(macsec, tx_sa, true, ctx->secy->netdev, 0); + mlx5e_macsec_cleanup_sa_fs(macsec, tx_sa, true, ctx->secy->netdev, 0); } for (i = 0; i < MACSEC_NUM_AN; ++i) { @@ -1187,7 +1207,7 @@ static int mlx5e_macsec_upd_secy(struct macsec_context *ctx) continue; if (tx_sa->assoc_num == tx_sc->encoding_sa && tx_sa->active) { - err = mlx5e_macsec_init_sa(ctx, tx_sa, tx_sc->encrypt, true, NULL); + err = mlx5e_macsec_init_sa_fs(ctx, tx_sa, tx_sc->encrypt, true, NULL); if (err) goto out; } From patchwork Tue Feb 20 03:29:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13563346 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0376E53819 for ; Tue, 20 Feb 2024 03:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399792; cv=none; b=U06DPfbkG9Lvf1MuBqXQz5qZUSqpWiaEG/Iw2fg7oIGYiBrOGH/KeEF8u7gJt2sJxu3xnNpGRtFlN6J9LFwg9tiB27sYa8yKaQomo30AEn7i/WvX/PLwoLnqLIeoy+WC65wMFCSZpUmOBvx5T3gka1Vtoer5QUwR+9Il3jDrsd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399792; c=relaxed/simple; bh=yhLy9sbURi1lyacWjFmHZjGF3VNx2Htxnj2UHBzwBVY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VnB9JdyMWX8pY40XtHQU3fjggWerHtDKecpUOX59YIZNNoGq6DcfxpehL+Bhxn3LIOFQp7uyLG5+VQNhCuBWpfrI0yvVYmASYy7gB+Iqfy300tEND2MCZLUJHQMctq2LjG3S5ooC5YtYFL+jhUfBp7lApILXlIgpc4gEH1bWAv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jr9Ft90n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jr9Ft90n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B305EC433C7; Tue, 20 Feb 2024 03:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708399791; bh=yhLy9sbURi1lyacWjFmHZjGF3VNx2Htxnj2UHBzwBVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jr9Ft90nrq28mChv9K+8bjZTc74ny0+b5zI90wrGTOnqYSGk0jQEm9DWyHZVPM3lk /ei25J6hrLQTKxz+zlEqke3IbmJ/c+Iq+tSI6JrHo2la3qG0X1JicEvgNuIuvasPF1 LHjx947lpkel3ykYK9z9DT6gF4c8BgcWvZxCSZrWX+Hf/KEJSNCkVvPhW7WgRzi/jx T86PtbkYE6FaZVszSGkP9rCu6DoY5Vsas5fZ1eljR+uXohzWWo3N8sJfw5m5k/+Snu /Ak6+1oeckYVjKkVxjx2f+uM0Ll7mw7ePZQYmd69zIZdpjIOiSX0v0k2JT/ZELHkhS DkVBPcFWTkj8w== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky Subject: [net 08/10] net/mlx5e: RSS, Unconfigure RXFH after changing channels number Date: Mon, 19 Feb 2024 19:29:46 -0800 Message-ID: <20240220032948.35305-3-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Carolina Jubran Changing the channels number after configuring the receive flow hash indirection table may alter the RSS table size. The previous configuration may no longer be compatible with the current receive flow hash indirection table. Whenever the channels number is modified, unconfigure the receive flow hash indirection table and revert it to a uniform table. 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 --- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index cc51ce16df14..ae459570c9ef 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -435,6 +435,7 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, struct mlx5e_params *cur_params = &priv->channels.params; unsigned int count = ch->combined_count; struct mlx5e_params new_params; + bool rxfh_configured; bool arfs_enabled; int rss_cnt; bool opened; @@ -492,10 +493,25 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, if (arfs_enabled) mlx5e_arfs_disable(priv->fs); + /* Changing the channels number can affect the size of the RXFH indir table. + * Therefore, if the RXFH was previously configured, + * unconfigure it to ensure that the RXFH is reverted to a uniform table. + */ + rxfh_configured = netif_is_rxfh_configured(priv->netdev); + if (rxfh_configured) + priv->netdev->priv_flags &= ~IFF_RXFH_CONFIGURED; + /* Switch to new channels, set new parameters and close old ones */ err = mlx5e_safe_switch_params(priv, &new_params, mlx5e_num_channels_changed_ctx, NULL, true); - + if (rxfh_configured) { + /* Revert the RXFH configured */ + if (err) + priv->netdev->priv_flags |= IFF_RXFH_CONFIGURED; + else + netdev_warn(priv->netdev, "%s: RXFH table entries reverting to default\n", + __func__); + } if (arfs_enabled) { int err2 = mlx5e_arfs_enable(priv->fs); From patchwork Tue Feb 20 03:29:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13563347 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 02C4D55C16 for ; Tue, 20 Feb 2024 03:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399793; cv=none; b=ooFyoTMWdaNGQUK7kwDl815wfdUvYu+Ik0y2BHCfXiPUQu3/6D4JIZtAF6pDWBjMbOQQtI8GwMfscJHYXdkG4mzkae3YAgrJBODL9Rwwg33OOqZphvv8Jt3iDpc3Il7vij8oILoeML35crCvA7QeQVJsxEixtvZGHVltUXC5/JA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399793; c=relaxed/simple; bh=RvD2dqrDB7aGGp2nRl6ceYDYfAesiG2xJqCHgN+uxBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kX3Q8+HHHsdvMbcBp+23k/vfuUIgowUQdhfw7SME+DIE402tLk0Vv9wnJKBMK2ITf1K0GMI8uk27U7SwEeKjDyKbDwI6nJyWbo1W8NO1S6rR603Ge2ASBm2vlQmGrpkd2PfaEoETrsNQQIfs3Oe71o441aWZqdflzsv6h2LEp6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DTNVfPZS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DTNVfPZS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C454FC433B1; Tue, 20 Feb 2024 03:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708399792; bh=RvD2dqrDB7aGGp2nRl6ceYDYfAesiG2xJqCHgN+uxBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DTNVfPZSWi3wMp6Rs4qHhmHM2htT8iW7dU1Cp8SMOr4Rpw5+nDBF6A7rABGwETlk4 Le7MTpTm8jP5fa7Qcbj+DWHywb34IHRr08tUKGmdwL4TwVldsJQ5T+3ffMp+N4XZhv P23knQui5mLG5P8ADtyvv9NlR5q/JL0C15F/X77aTptGTAvqHG6/SG6MYhEZ4WQfZa W2IKL9Sq6FcAcfAdyeTrZQ7QeCPHf0QInJO+Tz9tbSuzpbUH2g4sQWLRGA+NVL2nox gFAtsYt+rY9aQmwHGy7+yzNc5RR50wGQjCIh+ljtmSBfUJD070r+l2o8Moat/pMCcS c/8SeUuMy0kPQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky Subject: [net 09/10] net/mlx5e: Use a memory barrier to enforce PTP WQ xmit submission tracking occurs after populating the metadata_map Date: Mon, 19 Feb 2024 19:29:47 -0800 Message-ID: <20240220032948.35305-4-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Rahul Rameshbabu Just simply reordering the functions mlx5e_ptp_metadata_map_put and mlx5e_ptpsq_track_metadata in the mlx5e_txwqe_complete context is not good enough since both the compiler and CPU are free to reorder these two functions. If reordering does occur, the issue that was supposedly fixed by 7e3f3ba97e6c ("net/mlx5e: Track xmit submission to PTP WQ after populating metadata map") will be seen. This will lead to NULL pointer dereferences in mlx5e_ptpsq_mark_ts_cqes_undelivered in the NAPI polling context due to the tracking list being populated before the metadata map. Fixes: 7e3f3ba97e6c ("net/mlx5e: Track xmit submission to PTP WQ after populating metadata map") Signed-off-by: Rahul Rameshbabu Signed-off-by: Saeed Mahameed CC: Vadim Fedorenko --- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index 5c166d9d2dca..2fa076b23fbe 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c @@ -401,6 +401,8 @@ mlx5e_txwqe_complete(struct mlx5e_txqsq *sq, struct sk_buff *skb, mlx5e_skb_cb_hwtstamp_init(skb); mlx5e_ptp_metadata_map_put(&sq->ptpsq->metadata_map, skb, metadata_index); + /* ensure skb is put on metadata_map before tracking the index */ + wmb(); mlx5e_ptpsq_track_metadata(sq->ptpsq, metadata_index); if (!netif_tx_queue_stopped(sq->txq) && mlx5e_ptpsq_metadata_freelist_empty(sq->ptpsq)) { From patchwork Tue Feb 20 03:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13563348 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 50BD756B85 for ; Tue, 20 Feb 2024 03:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399794; cv=none; b=R9P/bfgPi7b2m3L/DUPeM8gZjfLkDzzVCItAnEcPkEnzpJ2mH3GLm+Zjzj+esolxJrGpBrSRcU5/1nfhcl/iQebNapNTCf2QZiulLJsd0M+Bkyk2T30WaAkTPZfW34I/smMMZbfkP5Os8fR15IN0gLMFy7KMGPMnu80BQNq1HSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399794; c=relaxed/simple; bh=Asbp0e0UT3h4Yq0AtejhBzjhgbz71HzZ/BSbV/Zutn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EXQ78PDSgPPME8+lyAJ3UMkeNaczaVr03CZaXCl7P/pczGdxQjQOCbYodf4lTK7MOpjbVY1TSH7u6qpJL7ktkhRLU/tkHH2cMTtdIwTNtFzj0JTsMZuJLZ7UIf8aB/LNa573r7GDHRtKeucFNvYI+Vi60obBXs+LBLBzQLkUXlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jpd0a0yn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jpd0a0yn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6214C433F1; Tue, 20 Feb 2024 03:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708399793; bh=Asbp0e0UT3h4Yq0AtejhBzjhgbz71HzZ/BSbV/Zutn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jpd0a0ynFncAbblajTYdCTWozMgy0Bye93tJ60mhKmUPI3lFvRWKRlE5OM5cd3Ema uOldeDnDPUp0uN2K4XbEoaMC1u7IerUtr3ySoY4QGxV2gmzM+wfW6TTwwXXhy1XyGR KvMW3C5VIwDIWnWfawRMo16EQC1HBSIYP1csnHfCDR2MxFCw7I1Q5QGKsu77gOA9SQ jv7Cq1vQh24jzyVvA9q8YgjY0qJByTznq5YvMOslcHe2gkkF0kck/DJ+sfsDTQIh6Q qi5rea6++5fWgGKahX8k33UiDS/isHIuku+27HryZFTsDtfrsuKRf/yUo667LD0hTQ BSQBNkJDMzEtA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Gal Pressman , Leon Romanovsky Subject: [net 10/10] net/mlx5e: Switch to using _bh variant of of spinlock API in port timestamping NAPI poll context Date: Mon, 19 Feb 2024 19:29:48 -0800 Message-ID: <20240220032948.35305-5-saeed@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219182320.8914-1-saeed@kernel.org> References: <20240219182320.8914-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Rahul Rameshbabu The NAPI poll context is a softirq context. Do not use normal spinlock API in this context to prevent concurrency issues. Fixes: 3178308ad4ca ("net/mlx5e: Make tx_port_ts logic resilient to out-of-order CQEs") Signed-off-by: Rahul Rameshbabu Signed-off-by: Saeed Mahameed CC: Vadim Fedorenko --- drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c index 078f56a3cbb2..ca05b3252a1b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c @@ -42,9 +42,9 @@ mlx5e_ptp_port_ts_cqe_list_add(struct mlx5e_ptp_port_ts_cqe_list *list, u8 metad WARN_ON_ONCE(tracker->inuse); tracker->inuse = true; - spin_lock(&list->tracker_list_lock); + spin_lock_bh(&list->tracker_list_lock); list_add_tail(&tracker->entry, &list->tracker_list_head); - spin_unlock(&list->tracker_list_lock); + spin_unlock_bh(&list->tracker_list_lock); } static void @@ -54,9 +54,9 @@ mlx5e_ptp_port_ts_cqe_list_remove(struct mlx5e_ptp_port_ts_cqe_list *list, u8 me WARN_ON_ONCE(!tracker->inuse); tracker->inuse = false; - spin_lock(&list->tracker_list_lock); + spin_lock_bh(&list->tracker_list_lock); list_del(&tracker->entry); - spin_unlock(&list->tracker_list_lock); + spin_unlock_bh(&list->tracker_list_lock); } void mlx5e_ptpsq_track_metadata(struct mlx5e_ptpsq *ptpsq, u8 metadata) @@ -155,7 +155,7 @@ static void mlx5e_ptpsq_mark_ts_cqes_undelivered(struct mlx5e_ptpsq *ptpsq, struct mlx5e_ptp_metadata_map *metadata_map = &ptpsq->metadata_map; struct mlx5e_ptp_port_ts_cqe_tracker *pos, *n; - spin_lock(&cqe_list->tracker_list_lock); + spin_lock_bh(&cqe_list->tracker_list_lock); list_for_each_entry_safe(pos, n, &cqe_list->tracker_list_head, entry) { struct sk_buff *skb = mlx5e_ptp_metadata_map_lookup(metadata_map, pos->metadata_id); @@ -170,7 +170,7 @@ static void mlx5e_ptpsq_mark_ts_cqes_undelivered(struct mlx5e_ptpsq *ptpsq, pos->inuse = false; list_del(&pos->entry); } - spin_unlock(&cqe_list->tracker_list_lock); + spin_unlock_bh(&cqe_list->tracker_list_lock); } #define PTP_WQE_CTR2IDX(val) ((val) & ptpsq->ts_cqe_ctr_mask)