From patchwork Sun Oct 23 17:22:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13016360 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 759BEC3A59D for ; Sun, 23 Oct 2022 17:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbiJWRXM (ORCPT ); Sun, 23 Oct 2022 13:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbiJWRXK (ORCPT ); Sun, 23 Oct 2022 13:23:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B12D75380 for ; Sun, 23 Oct 2022 10:23:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A797660BC2 for ; Sun, 23 Oct 2022 17:23:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85904C433C1; Sun, 23 Oct 2022 17:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666545788; bh=eX6K9xnIqhQ4Oz1yeOVn7ELD2CoAOFURGdmLXn2enYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQQQBwxmdCd5PPTJ397A6wb8Sd2pkKOjSXSZ644F2ClFdg0BY+4HPP1A1BXLgkOS0 rjqikASrmig9C/YlVC+dDjKJF/iT/rUgqBd0jN6sO1PRWCpa5cOjek/yPxgUqdZria gH8fsJQNyhmNJp06xlZeAnx3BwDvXBpDVeWfTZRSKzVHlbIwfOy3AJp5EPn21ahxGf 59MgtfhCnx99awkVSbl2gZN4BFUYSbXa45t/lrt5k08J2enNJgpdQOAeW8Xpa5fFeK ogWf0Rl/GxnI1nSEeoYzq3wzU053FRe7toTG8Cy2aNB6+xEnSdiFOcEAEDFOUXzizP z1WBiPPgzwKKQ== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Eric Dumazet , netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed Subject: [PATCH net-next 1/6] net/mlx5e: Support devlink reload of IPsec core Date: Sun, 23 Oct 2022 20:22:53 +0300 Message-Id: <862c2bab5b9a17c6a552d2e243909b9daf5d73d6.1666545480.git.leonro@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky Change IPsec initialization flow to allow future creation of hardware resources that should be released and allocated during devlink reload operation. As part of that change, update function signature to be void as no callers are actually interested in it. Signed-off-by: Leon Romanovsky --- .../mellanox/mlx5/core/en_accel/ipsec.c | 17 ++++++++--------- .../mellanox/mlx5/core/en_accel/ipsec.h | 5 ++--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 8 +++----- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 13 +++++++------ 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c index 2a8fd7020622..325b56ff3e8c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c @@ -348,29 +348,27 @@ static void mlx5e_xfrm_free_state(struct xfrm_state *x) kfree(sa_entry); } -int mlx5e_ipsec_init(struct mlx5e_priv *priv) +void mlx5e_ipsec_init(struct mlx5e_priv *priv) { struct mlx5e_ipsec *ipsec; - int ret; + int ret = -ENOMEM; if (!mlx5_ipsec_device_caps(priv->mdev)) { netdev_dbg(priv->netdev, "Not an IPSec offload device\n"); - return 0; + return; } ipsec = kzalloc(sizeof(*ipsec), GFP_KERNEL); if (!ipsec) - return -ENOMEM; + return; hash_init(ipsec->sadb_rx); spin_lock_init(&ipsec->sadb_rx_lock); ipsec->mdev = priv->mdev; ipsec->wq = alloc_ordered_workqueue("mlx5e_ipsec: %s", 0, priv->netdev->name); - if (!ipsec->wq) { - ret = -ENOMEM; + if (!ipsec->wq) goto err_wq; - } ret = mlx5e_accel_ipsec_fs_init(ipsec); if (ret) @@ -378,13 +376,14 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv) priv->ipsec = ipsec; netdev_dbg(priv->netdev, "IPSec attached to netdevice\n"); - return 0; + return; err_fs_init: destroy_workqueue(ipsec->wq); err_wq: kfree(ipsec); - return (ret != -EOPNOTSUPP) ? ret : 0; + mlx5_core_err(priv->mdev, "IPSec initialization failed, %d\n", ret); + return; } void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h index 16bcceec16c4..4c47347d0ee2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h @@ -146,7 +146,7 @@ struct mlx5e_ipsec_sa_entry { struct mlx5e_ipsec_modify_state_work modify_work; }; -int mlx5e_ipsec_init(struct mlx5e_priv *priv); +void mlx5e_ipsec_init(struct mlx5e_priv *priv); void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv); void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv); @@ -174,9 +174,8 @@ mlx5e_ipsec_sa2dev(struct mlx5e_ipsec_sa_entry *sa_entry) return sa_entry->ipsec->mdev; } #else -static inline int mlx5e_ipsec_init(struct mlx5e_priv *priv) +static inline void mlx5e_ipsec_init(struct mlx5e_priv *priv) { - return 0; } static inline void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 364f04309149..8867fee0db1c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5225,10 +5225,6 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev, } priv->fs = fs; - err = mlx5e_ipsec_init(priv); - if (err) - mlx5_core_err(mdev, "IPSec initialization failed, %d\n", err); - err = mlx5e_ktls_init(priv); if (err) mlx5_core_err(mdev, "TLS initialization failed, %d\n", err); @@ -5241,7 +5237,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) { mlx5e_health_destroy_reporters(priv); mlx5e_ktls_cleanup(priv); - mlx5e_ipsec_cleanup(priv); mlx5e_fs_cleanup(priv->fs); } @@ -5370,6 +5365,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) int err; mlx5e_fs_init_l2_addr(priv->fs, netdev); + mlx5e_ipsec_init(priv); err = mlx5e_macsec_init(priv); if (err) @@ -5433,6 +5429,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv) mlx5_lag_remove_netdev(mdev, priv->netdev); mlx5_vxlan_reset_to_default(mdev->vxlan); mlx5e_macsec_cleanup(priv); + mlx5e_ipsec_cleanup(priv); } int mlx5e_update_nic_rx(struct mlx5e_priv *priv) @@ -5885,6 +5882,7 @@ static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state) return -ENODEV; mlx5e_detach_netdev(priv); + mlx5e_destroy_mdev_resources(mdev); return 0; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 794cd8dfe9c9..061240e4eaf5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -761,7 +761,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev, struct net_device *netdev) { struct mlx5e_priv *priv = netdev_priv(netdev); - int err; priv->fs = mlx5e_fs_init(priv->profile, mdev, !test_bit(MLX5E_STATE_DESTROYING, &priv->state)); @@ -770,10 +769,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev, return -ENOMEM; } - err = mlx5e_ipsec_init(priv); - if (err) - mlx5_core_err(mdev, "Uplink rep IPsec initialization failed, %d\n", err); - mlx5e_vxlan_set_netdev_info(priv); mlx5e_build_rep_params(netdev); mlx5e_timestamp_init(priv); @@ -783,7 +778,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev, static void mlx5e_cleanup_rep(struct mlx5e_priv *priv) { mlx5e_fs_cleanup(priv->fs); - mlx5e_ipsec_cleanup(priv); } static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) @@ -1074,6 +1068,8 @@ static void mlx5e_rep_enable(struct mlx5e_priv *priv) { struct mlx5e_rep_priv *rpriv = priv->ppriv; + mlx5e_ipsec_init(priv); + mlx5e_set_netdev_mtu_boundaries(priv); mlx5e_rep_neigh_init(rpriv); } @@ -1083,6 +1079,7 @@ static void mlx5e_rep_disable(struct mlx5e_priv *priv) struct mlx5e_rep_priv *rpriv = priv->ppriv; mlx5e_rep_neigh_cleanup(rpriv); + mlx5e_ipsec_cleanup(priv); } static int mlx5e_update_rep_rx(struct mlx5e_priv *priv) @@ -1122,6 +1119,8 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv) struct mlx5_core_dev *mdev = priv->mdev; u16 max_mtu; + mlx5e_ipsec_init(priv); + netdev->min_mtu = ETH_MIN_MTU; mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1); netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu); @@ -1168,6 +1167,8 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv) mlx5e_rep_tc_disable(priv); mlx5_lag_remove_netdev(mdev, priv->netdev); mlx5_vxlan_reset_to_default(mdev->vxlan); + + mlx5e_ipsec_cleanup(priv); } static MLX5E_DEFINE_STATS_GRP(sw_rep, 0); From patchwork Sun Oct 23 17:22:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13016361 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FB2EC3A59D for ; Sun, 23 Oct 2022 17:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbiJWRXV (ORCPT ); Sun, 23 Oct 2022 13:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbiJWRXS (ORCPT ); Sun, 23 Oct 2022 13:23:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E83D74E3E for ; Sun, 23 Oct 2022 10:23:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EEA7E60A48 for ; Sun, 23 Oct 2022 17:23:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCE3FC433C1; Sun, 23 Oct 2022 17:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666545792; bh=pP9hlLMujiVLzkBS4BAe+6oUuA9UHzDEnbtXDhe6idM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=azjHJhW7KeWhBDUFla88IeApkjy2NEd7V39RfSVUEu89hDfjinS+XJCcP4Uml3Tyt ef7WBFhY2fphU4rYLxIS+qVPCGb4I/ur4S/adLzD/S0xLRKhqI2X+halFE+UHOo/AH 7RFzYxBzvTQY5wuUWhtDK3O0UD+gTlAv0oGmXiz47Wj+5SNsh97nLqdgK0J9fRPb3f +IfcUaibFh+BzJYLi4BR5EvSelp15y0d4+SD5vyC6AEGDC6KIhikkopqTQtlx+o3cY Rq0QiUQydRO6xh04xi3aSyLhy38OE53yKHgCMhhOTrU9bj0VxyWa9eXHmlZnel1zrT T3DHQSDEqr5dA== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Eric Dumazet , netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed Subject: [PATCH net-next 2/6] net/mlx5: Return ready to use ASO WQE Date: Sun, 23 Oct 2022 20:22:54 +0300 Message-Id: <081372b10853d727085470e1f389dd29ca29479f.1666545480.git.leonro@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky There is no need in hiding returned ASO WQE type by providing void*, use the real type instead. Do it together with zeroing that memory, so ASO WQE will be ready to use immediately. Signed-off-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/en/tc/meter.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c | 7 +++++-- drivers/net/ethernet/mellanox/mlx5/core/lib/aso.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/meter.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/meter.c index be74e1403328..25cd449e8aad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/meter.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/meter.c @@ -162,7 +162,6 @@ mlx5e_tc_meter_modify(struct mlx5_core_dev *mdev, MLX5_ACCESS_ASO_OPC_MOD_FLOW_METER); aso_ctrl = &aso_wqe->aso_ctrl; - memset(aso_ctrl, 0, sizeof(*aso_ctrl)); aso_ctrl->data_mask_mode = MLX5_ASO_DATA_MASK_MODE_BYTEWISE_64BYTE << 6; aso_ctrl->condition_1_0_operand = MLX5_ASO_ALWAYS_TRUE | MLX5_ASO_ALWAYS_TRUE << 4; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c index baa8092f335e..88655d5746d6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c @@ -349,12 +349,15 @@ void mlx5_aso_build_wqe(struct mlx5_aso *aso, u8 ds_cnt, cseg->general_id = cpu_to_be32(obj_id); } -void *mlx5_aso_get_wqe(struct mlx5_aso *aso) +struct mlx5_aso_wqe *mlx5_aso_get_wqe(struct mlx5_aso *aso) { + struct mlx5_aso_wqe *wqe; u16 pi; pi = mlx5_wq_cyc_ctr2ix(&aso->wq, aso->pc); - return mlx5_wq_cyc_get_wqe(&aso->wq, pi); + wqe = mlx5_wq_cyc_get_wqe(&aso->wq, pi); + memset(wqe, 0, sizeof(*wqe)); + return wqe; } void mlx5_aso_post_wqe(struct mlx5_aso *aso, bool with_data, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.h index 2d40dcf9d42e..4312614bf3bc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.h @@ -77,7 +77,7 @@ enum { struct mlx5_aso; -void *mlx5_aso_get_wqe(struct mlx5_aso *aso); +struct mlx5_aso_wqe *mlx5_aso_get_wqe(struct mlx5_aso *aso); void mlx5_aso_build_wqe(struct mlx5_aso *aso, u8 ds_cnt, struct mlx5_aso_wqe *aso_wqe, u32 obj_id, u32 opc_mode); From patchwork Sun Oct 23 17:22:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13016364 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DD80ECAAA1 for ; Sun, 23 Oct 2022 17:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbiJWRXe (ORCPT ); Sun, 23 Oct 2022 13:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbiJWRXa (ORCPT ); Sun, 23 Oct 2022 13:23:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12CC76467 for ; Sun, 23 Oct 2022 10:23:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 411DEB80DB7 for ; Sun, 23 Oct 2022 17:23:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C147C43470; Sun, 23 Oct 2022 17:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666545805; bh=oTQX8U0CkCI1jZO7NeZVpll2bILxaj0l8QSH7FuhFX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJUTq9FRvFVGhd5OhExYa7LGS/6b1k6o9tqYCjaQecgcblwDMWDbvYBZmeR13tXaN QhSaulSwMahL89JhIyQncXWcsWzQ4fqPt8iRRh8pPvpVocKttPvdR56KcXpPh+aUSB wzHLhcx3raa4UViTY93Z2aAu3IV08oLBQTJ6keJ/brxFfGEiUR1GZZ0xWwI1zaRCBu 3GbAGuHXQ5+Q4oAZbf4NX36kmfqZA8YtVNFeU0HK088ltCQOliVJ6yHrds+PZOo2sY MiygB48bX5ngdRgCVmB+vRv/8nwNBOUoVJYDafp39zySTqik1+98WBDfPQUGNWuqMJ cbnnO4BEspOQg== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Eric Dumazet , netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed Subject: [PATCH net-next 3/6] net/mlx5e: Don't access directly DMA device pointer Date: Sun, 23 Oct 2022 20:22:55 +0300 Message-Id: <18c347546df19a654fa6275ce9252db3db861398.1666545480.git.leonro@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky Use specialized helper to fetch DMA device pointer. Signed-off-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 41970067917b..4831a3e9556c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -186,7 +186,7 @@ static int mlx5e_macsec_aso_reg_mr(struct mlx5_core_dev *mdev, struct mlx5e_macs return err; } - dma_device = &mdev->pdev->dev; + dma_device = mlx5_core_dma_dev(mdev); dma_addr = dma_map_single(dma_device, umr->ctx, sizeof(umr->ctx), DMA_BIDIRECTIONAL); err = dma_mapping_error(dma_device, dma_addr); if (err) { From patchwork Sun Oct 23 17:22:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13016362 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A613AC3A59D for ; Sun, 23 Oct 2022 17:23:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbiJWRXY (ORCPT ); Sun, 23 Oct 2022 13:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbiJWRXU (ORCPT ); Sun, 23 Oct 2022 13:23:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F244376446 for ; Sun, 23 Oct 2022 10:23:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8D6AD60F1F for ; Sun, 23 Oct 2022 17:23:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 228A2C433C1; Sun, 23 Oct 2022 17:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666545797; bh=KYKuArPRPezhrsnq3FKdgkwpe2SLnUERWpSClufnIX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFk7SJ3YDzcy5B1f7S7BjdHv3oh36IumZ//KxFcwQIv/cN9xASTwT3n3bVJI16dNz X4qf0UKrTI7vFdN02Y7Pd1qN5J+ZHz4NhMCO8l2HRHz3rUBcfsXF4SPH+DX2nrNGVS DuZzGJyy/QtKlx2BvfIPaKuIu8b+L8yA7GwGcqYwtI7nwD62h8wRfquJDUypT4jkB2 Lzh1wlzOehd+7ZatSympfTwd4eaAHzBYXviLC0xdYjYdhW3Tb24ul78FEan1KyeSm+ /sX+H/U6p4rtCpnPw4AutOy39ZnPzW3NOpbNU6TflIx8im79dpwrCfqO5pHQkCLep7 zpUe9vGcuFHBA== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Eric Dumazet , netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed Subject: [PATCH net-next 4/6] net/mlx5e: Delete always true DMA check Date: Sun, 23 Oct 2022 20:22:56 +0300 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky DMA address always exists for MACsec ASO object. Signed-off-by: Leon Romanovsky --- .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 4831a3e9556c..f1e77ebd8630 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -1304,11 +1304,10 @@ static void macsec_aso_build_wqe_ctrl_seg(struct mlx5e_macsec_aso *macsec_aso, struct mlx5_aso_ctrl_param *param) { memset(aso_ctrl, 0, sizeof(*aso_ctrl)); - if (macsec_aso->umr->dma_addr) { - aso_ctrl->va_l = cpu_to_be32(macsec_aso->umr->dma_addr | ASO_CTRL_READ_EN); - aso_ctrl->va_h = cpu_to_be32((u64)macsec_aso->umr->dma_addr >> 32); - aso_ctrl->l_key = cpu_to_be32(macsec_aso->umr->mkey); - } + aso_ctrl->va_l = + cpu_to_be32(macsec_aso->umr->dma_addr | ASO_CTRL_READ_EN); + aso_ctrl->va_h = cpu_to_be32((u64)macsec_aso->umr->dma_addr >> 32); + aso_ctrl->l_key = cpu_to_be32(macsec_aso->umr->mkey); if (!param) return; From patchwork Sun Oct 23 17:22:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13016363 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08912C3A59D for ; Sun, 23 Oct 2022 17:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbiJWRXd (ORCPT ); Sun, 23 Oct 2022 13:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230446AbiJWRXa (ORCPT ); Sun, 23 Oct 2022 13:23:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0B36EF22 for ; Sun, 23 Oct 2022 10:23:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B57A7B80BA4 for ; Sun, 23 Oct 2022 17:23:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D67E1C433D6; Sun, 23 Oct 2022 17:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666545801; bh=5f/vo3lD4aj6GUVNDP2M0RaiddL1sztGtnfA3jea7TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZGTSW5uXd2qXIBaUCmQwRAiv7ppYlmWJ6GbU9Pqat/X91BFp1JSDgK87jR5r3PVi 0wtk66BMFYniyKH3wU/fsIOghyGHyN5EwGg4iGbCaD6pEFr0cCwpZSx7kYgpmW2+b4 8J8ClKv7IEblkL1oauTObabZwV52VLn8hzKCq7h+hOaBJZtancAEY9qgx0fo4goJft qRNtfRO4/B0T6p9NymlhN2JfPfNnZRFBczfKj9kSs6hiBvUYyJyAX/Wz8rY4NBfEqx vx5g3Ta14Fm2/nxbOYHfyEUTlMHXiddnmbaYeL+pfnvo6R4c8DhCK0Z/49kLn4VK5m EdaFlsWEyPmdA== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Eric Dumazet , netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed Subject: [PATCH net-next 5/6] net/mlx5: Remove redundant check Date: Sun, 23 Oct 2022 20:22:57 +0300 Message-Id: <01b2995cbd049e1cef2b2ba32c25488c51f28b1e.1666545480.git.leonro@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky If ASO failed in creation, it won't be called to destroy either. The kernel coding pattern is to make sure that callers are calling to destroy only for valid objects. Signed-off-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c index 88655d5746d6..87605f142a20 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/aso.c @@ -327,9 +327,6 @@ struct mlx5_aso *mlx5_aso_create(struct mlx5_core_dev *mdev, u32 pdn) void mlx5_aso_destroy(struct mlx5_aso *aso) { - if (IS_ERR_OR_NULL(aso)) - return; - mlx5_aso_destroy_sq(aso); mlx5_aso_destroy_cq(&aso->cq); kfree(aso); From patchwork Sun Oct 23 17:22:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13016365 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F234ECAAA1 for ; Sun, 23 Oct 2022 17:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbiJWRXo (ORCPT ); Sun, 23 Oct 2022 13:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJWRXk (ORCPT ); Sun, 23 Oct 2022 13:23:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF10174E3B for ; Sun, 23 Oct 2022 10:23:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 76F37B80D62 for ; Sun, 23 Oct 2022 17:23:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A24E9C433D6; Sun, 23 Oct 2022 17:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666545810; bh=yuW7el0F/awf//zpBFtIEOq8MGuS5P3ADg01i9yaQM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RowVB+LSA449/fk0fodewSJZqwN+xn2e+weHScws2nBZ7p9qHSPrbX5f9ePDU4EVT awel8PGr535+euRAw/NGkG60s25hIuKuDvLIlBsGJl+uRme4+9c6IVVLfKg6Bn4spM 9FNyke6g/hxl3aHdFjC9aPjzlsm7qGdxgGQUu7NJVV2ApWjhGsXCsLrWTdESXq+Jdv lLs+rW6+jLQEsOt8tRas8lRPS0CENzovmIjUVFNKsgffSob9PIHndpHWRKbTx+0VuM z+CgRzHDKUwIoJJgWA3VZ9jRmKa0TV+6X8zX4YQXjjUuQxrvBnf3Tuak+xlu7zLzju mcKR/PnYr2KGg== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Eric Dumazet , netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed Subject: [PATCH net-next 6/6] net/mlx5e: Use read lock for eswitch get callbacks Date: Sun, 23 Oct 2022 20:22:58 +0300 Message-Id: <65ac0feba98470e18a12cb732f8b6aefb058c1f1.1666545480.git.leonro@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky In commit 367dfa121205 ("net/mlx5: Remove devl_unlock from mlx5_eswtich_mode_callback_enter") all functions were converted to use write lock without relation to their actual purpose. Change the devlink eswitch getters to use read and not write locks. Signed-off-by: Leon Romanovsky --- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index 4e50df3139c6..23ada3a71c60 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -3553,9 +3553,9 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode) if (IS_ERR(esw)) return PTR_ERR(esw); - down_write(&esw->mode_lock); + down_read(&esw->mode_lock); err = esw_mode_to_devlink(esw->mode, mode); - up_write(&esw->mode_lock); + up_read(&esw->mode_lock); return err; } @@ -3653,9 +3653,9 @@ int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode) if (IS_ERR(esw)) return PTR_ERR(esw); - down_write(&esw->mode_lock); + down_read(&esw->mode_lock); err = esw_inline_mode_to_devlink(esw->offloads.inline_mode, mode); - up_write(&esw->mode_lock); + up_read(&esw->mode_lock); return err; } @@ -3727,9 +3727,9 @@ int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, if (IS_ERR(esw)) return PTR_ERR(esw); - down_write(&esw->mode_lock); + down_read(&esw->mode_lock); *encap = esw->offloads.encap; - up_write(&esw->mode_lock); + up_read(&esw->mode_lock); return 0; }