From patchwork Sat Mar 2 07:03:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13579443 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 11E2111C88 for ; Sat, 2 Mar 2024 07:03:28 +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=1709363009; cv=none; b=EXSCEiOk+XpsohrMiBq2L5v8UjTS1/sMw4i3IyAt+zvFQxmR/A+b8R97GPdLWYNDZ7jdGyhry1aLdEVLCYbomhhcmGVMeWFkFEhwLKjDaAVd/Msf9iLOqQYiMXi158Bs09kqWyB+qo07p5y7kEg6s77/eihgLtQnXEng4LM3BKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363009; c=relaxed/simple; bh=QitwpCziBi0rtsdag0DWierUMBOna7KEGs9RTjNZGeE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=snmu8Rmglpov0zeHoUkt/6P4cF0xnOytfzrf3QWVnp7VyZy0vlTkEi05Lq0jh9iM60fesrNTyDyOzkLu80NXIoa7mYq0WT1PgPIc0VEa1f4zi4DWUcA59JKLWNN1fN0kFRf1p1U5zorTNwIrtoRMaEXnheSOXAY6GnUS6CXOwP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jB2dx1ln; 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="jB2dx1ln" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69184C43390; Sat, 2 Mar 2024 07:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363008; bh=QitwpCziBi0rtsdag0DWierUMBOna7KEGs9RTjNZGeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jB2dx1ln13aw7h7HW1m/1Yq9OHaT7L0Oni/SbcENc4jD2rLmBP6Dcll0El1nyxk+v kYJHJZxwX2LUp9LVirP6eVAHQiPEZ6NSWOOVGJlaitfEFEc2KWsfgu0rSLu8/pqTQ3 XwsknzRDQ9xgmMlwLbua/fyX9Qx0s24sjtcswOoAUB/0UtQRbknZUZODz1/YKeXHK7 Kw4PoLNtjopFGZqwfVkJTxU9GNzDJrGP60/dxwzvdrEwsn7kQCGuvp3gwfiD3PgLUs cqY6iryRBBRuamnObxUKTQczNpQ1bJyDEKdXtWufKR39cfltDx0oP8G//OjNfaeWqb i5gfed+NeQF2Q== 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 V2 1/9] Revert "net/mlx5: Block entering switchdev mode with ns inconsistency" Date: Fri, 1 Mar 2024 23:03:10 -0800 Message-ID: <20240302070318.62997-2-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:03: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: 13579444 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 933A3125BF for ; Sat, 2 Mar 2024 07:03:30 +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=1709363010; cv=none; b=u8xGkOhZyZVIFzfnJzHouvfpNHONPdcOflYxW/I57mvy1dfIfm60zOferjACH9/xUwSfgeqTlMSGr9uDWcqzBrUqAZQHO2FkmAKgOutWO6BUlkS/ufmpg8gitFjxZFi7ix1MMD4EfU1Xg7bCvp1ouxIN64VSTiX6s1YnojieZVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363010; c=relaxed/simple; bh=WhVPWAd6p6F3Iylzr4WUeY2Hrg+7aP6qB2ytDCgvv3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFkDfMCFIS/B3nRjl7/zgSupUrYhYPRXAU/lUPbKq6+OEB2vMq2qq11UFhcMajA0Vw/a9BvJiOh+i3wFWSAakoaIMzAG6yBbpqLGly+fDuYBj9EjMnTQFjgFNt4w7A3ty74TvGBUHAM56cQmNb3/1eaIVfTh70u3/QwZAHCbztc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sb/D3QiV; 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="sb/D3QiV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E12FDC43399; Sat, 2 Mar 2024 07:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363010; bh=WhVPWAd6p6F3Iylzr4WUeY2Hrg+7aP6qB2ytDCgvv3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sb/D3QiVgRnSXc9khx4L2kIjEjR1e5Ts8EQfA+w5Xhm0iwhEkTd92rmqJMJYEFrIW IzqSfPJX3tJxt5v//Egdz26GWTV1n+DfxoeSbLR7EE/V32vbDU3cxZkRxTdbXIswFK owD8eBaGA9vzca+1a6W64NOGRZ1Cnzx4Kl9b+YNo1Y3H7/D3WZ3jxxrTQShuBvZRAh tmxkcOlhEwOKdftVPIZYNQakIqsXUBsylCh5GdaTJ9VgAnKlWwek2juiuetSi0PqLA wIkN36j2tycBk7K0aN0nDVDocTe2nVQD9TE2le1hQQV1EZq33lcA8vYFN7KOKPrY8a ywHCSP1qOS10g== 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 V2 2/9] Revert "net/mlx5e: Check the number of elements before walk TC rhashtable" Date: Fri, 1 Mar 2024 23:03:11 -0800 Message-ID: <20240302070318.62997-3-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:03: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: 13579445 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 2B00F12B80 for ; Sat, 2 Mar 2024 07:03: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=1709363012; cv=none; b=LaF/0k3CXh8MJofK78r9KJKkmQVg6DiJo6Dk71R3PJLiPBHtCw6t6THzMDL97XMVh5mDGM97LQ2ZhTwE4qgmp09uYRUoXCRdyXohhwOF4MryqKrSL/DCoSEwatfGrWSJ6M4tTay7kCV4upuTRSeyMcoJgWGxQn//o/e9srJAhzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363012; c=relaxed/simple; bh=GQUbpXrbe8eCWaF4vdRQ65DJzEnH0Il8lWULM8R5/S4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wj3r449vNKaj9NcGtusTqdMXWbNQmEZDip0lXZXkED42EXJLW4+0qaTnH2ziYu75rmSaffas3a3O5efUS/fcLFCyesqf/eEGu2b/9yRXho/MaSynMmd3+4LVVecBaiBBw1kynN/0pd/Q6B8m7rHEWqhoKmBpk587iN3FiND8fxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eaP1Cc3Z; 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="eaP1Cc3Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93135C43399; Sat, 2 Mar 2024 07:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363011; bh=GQUbpXrbe8eCWaF4vdRQ65DJzEnH0Il8lWULM8R5/S4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eaP1Cc3Z3nDmvbREePzRRUFPQ/DnkEDzbIXshYl9mVN9zLW7f2opOjtcOzEla0hxh 20bWy1OCyoa4+Ek3IOmp5K5uz3JtW8uq0wpeayoYK8CjmQRfpMTzHfCtJUtkh+t8xg +nZVhkNp7Orootkeqr/qbw/CUOZs9DUGswhwUlQ3WZeT/U3tEU9GMf+PCx5Mqsh2up HcV4FvkYfaXC9Dr8et0CpzmPyilDT3k46BK+KVPnS2BrInch4mJB3l04jBL4oeJIFB AxRw8yFF7AhGl3fmQfTyM+I2f/siwIJs1nVYzGF5nMb78ird5oWHcvMtJ8hd5tEfx5 pFRlfIZRZJzAw== 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 V2 3/9] net/mlx5: E-switch, Change flow rule destination checking Date: Fri, 1 Mar 2024 23:03:12 -0800 Message-ID: <20240302070318.62997-4-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:03: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: 13579446 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 A740912E4A for ; Sat, 2 Mar 2024 07:03: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=1709363013; cv=none; b=ByVUdjzIAJDwWOIPr9mvRLDMbmTan16q4hnQGWL13fBWY/Co/3MJzwi0Jx3zVsaaXHFDSGV1JS4+5CPLWnlgYmixQcKTK32d50ft03cI/l8vuJ3JEi6lVsyHxv/Qjp4FYKTAcKSfvUJ8y8v/2eOKC9BEipAZxLKJIXv+Of3zh7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363013; c=relaxed/simple; bh=PpqABxeDDg9ys4JtXwZkNf2wUeYEgR+GbwRLVDSgfCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GVN3ll0zDia/pgFmBP4bT08dZxuEZ4bW+6Re1fYNOpdMyQAZ+a5E6PguEEUCDyaqfTwDnMjLnKvMFYcU/efi7/Uanm+HkyNEW0qwsl5dS0Tsfw1kV9k5yBjnnxo+rEUHYEMbAdgJpiNPfmqCKFtG7K7fQgi/POcUSNbSJIVLLUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W6D0s1lk; 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="W6D0s1lk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1772DC43390; Sat, 2 Mar 2024 07:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363013; bh=PpqABxeDDg9ys4JtXwZkNf2wUeYEgR+GbwRLVDSgfCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6D0s1lkpIfJzhtedUj4Rx9QhVcw+ytiamRadWBXC27abxwnH0rHzr/XimInVov6R cA5/wiRntBd/uNiB5XVWM9KhTr7hU+iB2jWrSPNLQCtRiFMa3luxEnS+HqitmMtG0B OSWXC3FlBz3efi1UIj61tHrRewo40Dx4dOv3PEh8spgs82qT+gwobRJ73MotKbk6Dj esqPfhoXAOekEdFS4Unln4SqU62oHiyNXt52bM8Ekzq/Gl/R+m6Aq2pF2jSuDery9E EPSklXsaC46d9VxuJDIEedDzhWnNFN5n/OD50/rD3qrAb9pMv4ByjnBVYbMh9jRNtR DkWMRtY890jIA== 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 V2 4/9] net/mlx5: Fix fw reporter diagnose output Date: Fri, 1 Mar 2024 23:03:13 -0800 Message-ID: <20240302070318.62997-5-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:03: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: 13579447 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 E2EF8134B9 for ; Sat, 2 Mar 2024 07:03: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=1709363015; cv=none; b=ToWA38arz0as5SDFhRQRk8rYer3SpiBNyFJAgFRy8hu53nsjNJfmLr1WXPxZ3BXcAQOpRC/Uc82PB1Y1HZYYntcTmhdq4CDNkm6QzApoz+ZBIBlLNb6WvA91eDIzqcqpyQYqPUIgMlT7TKDIixaThM+qBU0s52VoAAOzp5NNDTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363015; c=relaxed/simple; bh=4tjgh12z3BfQQcKFpRvP3NGXj5OkkYbsFNpq5oWOerQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q2B+rdQ2h/Nem7KxFEky0sdt5HFZ1sQwwrlidMh4zFXu6aj9MkJGbzRiol4LZNEqvfyzRgzUyjnqEeHUaEI1W7UpGXymUq/nEj99qqqX2n7Yx5xeA39rFjSnegNTVEvM+Ta38/bZlAJZQVNo6NwoFKODCiPTCf1wotf1ITVQFqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XBwHwxgW; 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="XBwHwxgW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 983B6C433F1; Sat, 2 Mar 2024 07:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363014; bh=4tjgh12z3BfQQcKFpRvP3NGXj5OkkYbsFNpq5oWOerQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XBwHwxgWyNJ4lDcQR1wCzdyq1kWwD7HhOBLHwwkjO/dHOEQIHp9C/5trFR4ztCvmy QlJWk3ZXa+tRpifZxENSeWVUfoKNsnmDiscHjvQOUbVJ/+2dnrUsF8PdVEHxcf/Duh PCT5luZ68PvkVNsDpWUzz9VjS2b8Yi2CgyydS+WOvGkMFUhth1akPy6Hk3CLDZWrbZ XyDjSbkK1yDIlT7ZWjKplO4PXAZAPEqntCcOuDPA/wwPs7dqr1PEV7YjCQtyQhCGG0 SFEgvQPvH61x9o4+d/ZO6GgTVok2uXejuCvzBkJhGCvOYhFGZqaWQnJe75fl47ZiqE I/6p9bt+y3reQ== 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 V2 5/9] net/mlx5: Check capability for fw_reset Date: Fri, 1 Mar 2024 23:03:14 -0800 Message-ID: <20240302070318.62997-6-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 3fd6310b6da6..486b7492050c 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 Sat Mar 2 07:10:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13579448 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 585F2748F for ; Sat, 2 Mar 2024 07:10: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=1709363431; cv=none; b=drGZM8wrtfEcJHs+tz3//a6IVP/YG2zSg12v9Is4pOu1x3djjH/2HiRre0AjXPvK5uUtGbwIYgpA7SOYHEKXyiUA+3eyP6yuDbQoSTMeusiT+ElEKpEI4HCVTCJZ2C3+gOH5cN31y6cJr0iIJm+7wZCzVYZvJj6R07/7h2TQ4P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363431; c=relaxed/simple; bh=hoLds3QC8f9sRNnKiSb8DW9tQdQjcXCfMTOmC45MsYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rhpllcO5InLFqZ5690RspSXmi7C/IXltGwFTm5IB0vEFXcKVwT2UzWubfxy14BJNGq6QRyz7wRaidDhvAsUDf6RZL2esf1LYpzoisg+WUoVs8S3pArJSeLI2RTyFYPmi5UTimnc0VG+jkYuFlOCtygX1ssG5sRkSoLxWJE2329s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EaIR+7wP; 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="EaIR+7wP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94AADC433C7; Sat, 2 Mar 2024 07:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363430; bh=hoLds3QC8f9sRNnKiSb8DW9tQdQjcXCfMTOmC45MsYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EaIR+7wPOggeV3r2sVCHo7HtERYualCnt7L5U2itXCGFMNBMrrExDIdJnbESNJBs9 sHHmmqT4VnwSkhbwVpb4YbS+GUtK7FWKzxprbVYeKy4CwsVkLYlwpDGaBo1nmW/Gy8 2xoxZE2LHBghyPJ/LV3D6lc5WrPawo3vRCg3cOyOwZXSQrJJJJd59Ipfd5PRRxMTRc uL0+kI+Df3ky69W56QKYszlsv1KtV7S4q7/RGoBzZkjD4i3IcIs07rE0EV1K4HVJ0F ewwF50SUfI9GuiYc6pTaA36UWKAID8HEfXtBD5RPp+1HIuad3Rub3cszTfh6AeXnml CL1d0kAFtc/Iw== 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 , Elliott, Robert , Roi Dayan Subject: [net V2 6/9] net/mlx5e: Change the warning when ignore_flow_level is not supported Date: Fri, 1 Mar 2024 23:10:25 -0800 Message-ID: <20240302071028.63879-1-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:10:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13579449 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 CFA961173F for ; Sat, 2 Mar 2024 07:10:32 +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=1709363432; cv=none; b=WlFx3mLEBjHG7lgfkFr+AlgEn6SOH3Q7uPAScHOhpx9KC1SH6PwEwm4Tzv2luwDFkknKAusEWZgJ+4vgnFCgmqR4nsd1tame9xZ9DSEGe3FKWfE9aM5ewjyckvgPe90BkanqgUeQbszIgcH4NvL+9lxHM9rXyiNIrWy3uiq9jOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363432; c=relaxed/simple; bh=gpBd/gJ0w5Hrbp4iQBH6YDhLFzNCTib1Q+IVTKvj6QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXqXVtrfrqQcS+zYlgYJZQyUwJ+GsYQ1WIqObcpD8vKMeufQz5NXIUlXHXVEjaclUytm9Wq/a1/IgffNBLnUUAJrPvFv//CnFPb5nMklrFxNFolTn8Rs+YttLAX33hANiQF5LA2MyEZnJvnbiyb1J6k/r+PRK6h8lW6zxUG/VbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=svgxx8tO; 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="svgxx8tO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2842CC433F1; Sat, 2 Mar 2024 07:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363432; bh=gpBd/gJ0w5Hrbp4iQBH6YDhLFzNCTib1Q+IVTKvj6QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=svgxx8tOdjvGxBXWoQmCCwaQN/XvmxISJFXXEjflAmxLcK9PClwfvpxluXc/XhKFe kqu4ZT0JgfmscG2wJy1gM+5Nako3MdQ4sFd7qziWvVw2fwgS5nySSYIzw/Gr2O7QFz jUCM3W/fLGMevmzyEPLSxtDkW318TH3IXlgwQDXcR3qSVwJnI7JAQgPs6vePYTQNSj YmYE+1bofl6srhTIfINAhYcTB7BH+ayC2gLnz2HyfkZcLNTJQjhs4rZxK0gxQln4kI XMXCjycPJbepXj1kCej0r6Z/urE3bzKKBZVAU3jtpwLk4o7rNUfP3Z1KQOLHIpLlwW Z4N8xCZW9OeHQ== 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 , Emeel Hakim , Rahul Rameshbabu Subject: [net V2 7/9] net/mlx5e: Fix MACsec state loss upon state update in offload path Date: Fri, 1 Mar 2024 23:10:26 -0800 Message-ID: <20240302071028.63879-2-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13579450 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 41E9F125AE for ; Sat, 2 Mar 2024 07:10: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=1709363434; cv=none; b=Dx8RkMZ2cjXYtsMvAfEyKmwHEzN01NeAkuiNhx3FBaU/pssuivuCtto6kjP/rXqj96Lp0Xv/U0ivYhsziZxEQN09thuIkgrlYsbJo4b0NLUM8yJ0q96JqIDnN8FAMnrsEgTJfvS/CEmgok7Zju/VrLNDSGPJ5HpRLHpYsDdkF5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363434; c=relaxed/simple; bh=hvEAZRltJofvb1WE/AOfuxeRJ7B5gwycw2IQCCI2Tcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YCk/wjPoStr0LaDGuVbdU8Nq4fWwtlmvZlxmbVMW2l4OzMwo5S5SBuNIzc6EUy6IhYClx7I96J1rW7o2fLnr5gybfAxzJAdQdRIK0qnA44utNDFJWgmo9pktX5hwngH5wwHe+CF+u88s9nf8BT/EVdKh1EXB0q8EIG/ZD2szB+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ns/lbYSe; 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="ns/lbYSe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7B2C433C7; Sat, 2 Mar 2024 07:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363433; bh=hvEAZRltJofvb1WE/AOfuxeRJ7B5gwycw2IQCCI2Tcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ns/lbYSebk7xG6XruCxKqpV552NpsRlQQNXCzqUucayA5K1WnfFNrFQJhr+Huii93 1oz//HX/1M8lH7qVeTrRRVgTDvU3XsqTdeztmugFaDfhi+raM6hfL/oHhEnx3ObET5 P/tBk731sf2AhDLf7JCSKdTzkQvk1I1PEMeoBnrmoFHxnLPdlVmeoWChND69ViKU8O gEJAWXxY9WaG1IyEjM7YekceXHmuQfvuyi31X0gkLE5jle8GKWKCycLAsVsNgzcpkM yVKO43jE88aaVMvGGS2kjEEkVOlLcLAEI9zvAzKtcfwLKLacjRK43JDjmIe85qZOPL GoGWJMuBJZBNg== 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 , Rahul Rameshbabu , Vadim Fedorenko Subject: [net V2 8/9] net/mlx5e: Use a memory barrier to enforce PTP WQ xmit submission tracking occurs after populating the metadata_map Date: Fri, 1 Mar 2024 23:10:27 -0800 Message-ID: <20240302071028.63879-3-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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 Sat Mar 2 07:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13579451 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 B982A12B81 for ; Sat, 2 Mar 2024 07:10:35 +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=1709363435; cv=none; b=RAdn8eRQLzr6UP013RLpOD7gY5kkpI1gaD6QWIMpuXtjihyjzdpM7Sl5V0t0lBF1K1w+1zZaZzScbxDHguoFg7SyMAGz2Hb1yJ8C/dqkgFvDAw7oOu+keFtvFGSc+uiU04cRKTzJnmluSbpzMU1Ya79u/1Sm3Elra0fqtSDDNHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709363435; c=relaxed/simple; bh=QILZuWBaR8rQwjMtzDdN+jV8tsTG/BqqLdc5vEV3Ne0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aPsub/VJo5asALHbTbAHy2oOUjZ/U/wIYw2k2DHrLgVFzDi6f6+pwywllr19TwsUcW2HCIAbgNjKnDT6XA21Age38lX3IraGi5B4GdJDHRGdX/2ev3p3nyby33isOy6DEh3Y0bht2+3EzrvyqJUQtkfLROovlUsbJtTknu75C5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SWrCkBza; 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="SWrCkBza" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EACFC43390; Sat, 2 Mar 2024 07:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709363435; bh=QILZuWBaR8rQwjMtzDdN+jV8tsTG/BqqLdc5vEV3Ne0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SWrCkBza8x1/GEWNWBFKUkcYUu4akpvap1p2DVTBbHNi2S0t131ph78Ubrcp28Qbb a9d6Ntzny3vd6QxcoTVYHVnn9BrdMCJr6Skb/MAeCRaQ5arBXuZJ7XbhbIkYNus/Ru s5GQAgfXLKrQj94iLjIk/UeAjggWVptHKJAGQv6vj22ZglekBhujcnzlBPBQ0X3LKe CVOI1QEDje8BXhwc5V3GUTzvSWZ3UwKG1IDmmtx0FprNwEsp/HbzB1NrVQI8UAqTgn 4CLOPG+7ZZfVTr6lOcDF2U/I+BovY1wRhrhoIpQHJ7c/jNRp0JxHZCShmbYVYP3ANA NIBtYlKI2UaoQ== 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 , Rahul Rameshbabu , Vadim Fedorenko Subject: [net V2 9/9] net/mlx5e: Switch to using _bh variant of of spinlock API in port timestamping NAPI poll context Date: Fri, 1 Mar 2024 23:10:28 -0800 Message-ID: <20240302071028.63879-4-saeed@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240302070318.62997-1-saeed@kernel.org> References: <20240302070318.62997-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)