Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp422066pxk; Sun, 30 Aug 2020 08:35:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDO2ZXVoAzD6t4DpXJpx8F8tDAeA1N6xD6/7Ze6uwin0j4XqqsR1Gvg0wLnEY5TSBU4YZI X-Received: by 2002:a17:906:6b87:: with SMTP id l7mr7768919ejr.198.1598801715291; Sun, 30 Aug 2020 08:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598801715; cv=none; d=google.com; s=arc-20160816; b=WSHdz+/lcUIClu25YJUDGii6RcM3PZyhkuDJtLpfRr9EHkPNvh/BuWtt5KmcLi+YaA he/mfrzrWIDzfWBcGLRebEapwSQaUxBnXXu9P8aMznNSpYOXQAQmTIk2iewIupmgrFwU EEYmWNpwtE2ruB6nGDB8S+at0UuFB8JF1k2uvg01ddhHMKl2L9ysKwDcImeDjYb1L/FJ wlpgQWZyqfHrgvt/asM7re1uUWVUF+jGuSgJCeDhHa7dqUYnFdLMobOuAwK/1pYvRjWA cwBbilUZU7sQbAX0NczZm9+M7aUtiJm9OV33MzjL6DkJDw16yffbwMdNSMpS5qz+e2XM RulA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=cMr7fqWeYXVVJpHq8DlCpLRdNTVENl0pXHv3G8yLYgU=; b=xstv3SymMrbTaozuhugNk9M1WkGEtTWMKotxIidWgIIHRJe2/oPzyZPM5DRoXAxcYB oRg8LLJoLK7TnjvyuxY9e8r7fMCPfeRlF9M84YTCXsMXEv5blNxdIFFEfoTKaBcczxJ8 5Iq0Y8cNq7EZZ/BmqJzUcG0HfPP/X4T8dGGV8aXB1qvlrMI0yiPT+IfNtFd6Wvma+6uo JeFxtJEDx07zI8GeapjBRq4WSlNIGlm7KeAnZQUeH2SWzmpn+jGMUyc9uOFA+2x++lPH PNX8mmmt7YyLZEAbH1sgORlFIH38HvO1A21jACq7oDs2HxQegOKXeFDidhk7nyQv687o 6J6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si3730807edq.314.2020.08.30.08.34.52; Sun, 30 Aug 2020 08:35:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726126AbgH3Pba (ORCPT + 99 others); Sun, 30 Aug 2020 11:31:30 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:42764 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726791AbgH3P2C (ORCPT ); Sun, 30 Aug 2020 11:28:02 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 30 Aug 2020 18:27:56 +0300 Received: from dev-l-vrt-135.mtl.labs.mlnx (dev-l-vrt-135.mtl.labs.mlnx [10.234.135.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 07UFRugu029669; Sun, 30 Aug 2020 18:27:56 +0300 Received: from dev-l-vrt-135.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-135.mtl.labs.mlnx (8.15.2/8.15.2/Debian-10) with ESMTP id 07UFRu1g027851; Sun, 30 Aug 2020 18:27:56 +0300 Received: (from moshe@localhost) by dev-l-vrt-135.mtl.labs.mlnx (8.15.2/8.15.2/Submit) id 07UFRuNb027850; Sun, 30 Aug 2020 18:27:56 +0300 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Moshe Shemesh Subject: [PATCH net-next RFC v3 11/14] net/mlx5: Add devlink param enable_remote_dev_reset support Date: Sun, 30 Aug 2020 18:27:31 +0300 Message-Id: <1598801254-27764-12-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1598801254-27764-1-git-send-email-moshe@mellanox.com> References: <1598801254-27764-1-git-send-email-moshe@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The enable_remote_dev_reset devlink param flags that the host admin allows resets by other hosts. In case it is cleared mlx5 host PF driver will send NACK on pci sync for firmware update reset request and the command will fail. By default enable_remote_dev_reset parameter is true, so pci sync for firmware update reset is enabled. Signed-off-by: Moshe Shemesh --- v1 -> v2: - Have MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST instead of MLX5_HEALTH_RESET_FLAGS_NACK_RESET_REQUEST --- .../net/ethernet/mellanox/mlx5/core/devlink.c | 21 +++++++++++++ .../ethernet/mellanox/mlx5/core/fw_reset.c | 30 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/fw_reset.h | 2 ++ 3 files changed, 53 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index f2f1f4e4ef25..ea759bb2a120 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -284,6 +284,24 @@ static int mlx5_devlink_large_group_num_validate(struct devlink *devlink, u32 id } #endif +static int mlx5_devlink_enable_remote_dev_reset_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + mlx5_fw_enable_remote_dev_reset_set(dev, ctx->val.vbool); + return 0; +} + +static int mlx5_devlink_enable_remote_dev_reset_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + ctx->val.vbool = mlx5_fw_enable_remote_dev_reset_get(dev); + return 0; +} + static const struct devlink_param mlx5_devlink_params[] = { DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_FLOW_STEERING_MODE, "flow_steering_mode", DEVLINK_PARAM_TYPE_STRING, @@ -299,6 +317,9 @@ static const struct devlink_param mlx5_devlink_params[] = { NULL, NULL, mlx5_devlink_large_group_num_validate), #endif + DEVLINK_PARAM_GENERIC(ENABLE_REMOTE_DEV_RESET, BIT(DEVLINK_PARAM_CMODE_RUNTIME), + mlx5_devlink_enable_remote_dev_reset_get, + mlx5_devlink_enable_remote_dev_reset_set, NULL), }; static void mlx5_devlink_set_params_init_values(struct devlink *devlink) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c index 1f9ad1f38d92..0df2ad9d555c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -5,6 +5,7 @@ enum { MLX5_FW_RESET_FLAGS_RESET_REQUESTED, + MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, MLX5_FW_RESET_FLAGS_PENDING_COMP }; @@ -22,6 +23,23 @@ struct mlx5_fw_reset { int ret; }; +void mlx5_fw_enable_remote_dev_reset_set(struct mlx5_core_dev *dev, bool enable) +{ + struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; + + if (enable) + clear_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags); + else + set_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags); +} + +bool mlx5_fw_enable_remote_dev_reset_get(struct mlx5_core_dev *dev) +{ + struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; + + return !test_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags); +} + static int mlx5_reg_mfrl_set(struct mlx5_core_dev *dev, u8 reset_level, u8 reset_type_sel, u8 sync_resp, bool sync_start) { @@ -76,6 +94,11 @@ static int mlx5_fw_set_reset_sync_ack(struct mlx5_core_dev *dev) return mlx5_reg_mfrl_set(dev, MLX5_MFRL_REG_RESET_LEVEL3, 0, 1, false); } +static int mlx5_fw_set_reset_sync_nack(struct mlx5_core_dev *dev) +{ + return mlx5_reg_mfrl_set(dev, MLX5_MFRL_REG_RESET_LEVEL3, 0, 2, false); +} + static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev) { struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset; @@ -169,7 +192,14 @@ static void mlx5_sync_reset_request_event(struct work_struct *work) struct mlx5_fw_reset *fw_reset = container_of(work, struct mlx5_fw_reset, reset_request_work); struct mlx5_core_dev *dev = fw_reset->dev; + int err; + if (test_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags)) { + err = mlx5_fw_set_reset_sync_nack(dev); + mlx5_core_warn(dev, "PCI Sync FW Update Reset Nack %s", + err ? "Failed" : "Sent"); + return; + } mlx5_sync_reset_set_reset_requested(dev); if (mlx5_fw_set_reset_sync_ack(dev)) mlx5_core_warn(dev, "PCI Sync FW Update Reset Ack Failed.\n"); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h index d7ee951a2258..fd558dfe93fc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h @@ -6,6 +6,8 @@ #include "mlx5_core.h" +void mlx5_fw_enable_remote_dev_reset_set(struct mlx5_core_dev *dev, bool enable); +bool mlx5_fw_enable_remote_dev_reset_get(struct mlx5_core_dev *dev); int mlx5_reg_mfrl_query(struct mlx5_core_dev *dev, u8 *reset_level, u8 *reset_type); int mlx5_fw_set_reset_sync(struct mlx5_core_dev *dev, u8 reset_type_sel); int mlx5_fw_set_live_patch(struct mlx5_core_dev *dev); -- 2.17.1