Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4745694pjb; Mon, 27 Jul 2020 04:11:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIHGGL8fkja72yLWKtcyNKzDZnV1zuSkeHwxZxVjGKe8CDy6PyLo0qGvqx9vDVo1QmjJct X-Received: by 2002:aa7:d1c8:: with SMTP id g8mr20787083edp.337.1595848292364; Mon, 27 Jul 2020 04:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595848292; cv=none; d=google.com; s=arc-20160816; b=mnekMydctiQU2kK89Q4XyC+XMQUTgznwlYuXDmA+JeKBtlXqQL8+0QMYpxIZRGOV/C H9OkH8PNWAMLCJuJ5LaIhzMwi3A6ivOAQg1X3ul+fyqBPhgyZUm0OGIwB9ZKJ5Tf4xHQ RI9UghkktLtIr+s35ZrMCX4FsB3mxm1E/blDqluAo+mDm2cg7YbvIMNklSAkFL2K9gR2 aLJLyLf6Q687zB4MM8Fznn3b6ADpUCx47bDBvS3ggdFacUysanX4rsjWlM1NWpQjzPgn jdUqpOofeV7HdLaLosfclEynXPGiQEQgXaL+QUIjmXzktztTj7qXSKnYQwtwqf1Uh94S MsXQ== 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=NdqH7gX4/F4s+KKc4LVtw5XkG/IXED0JQB6BlBQyBKI=; b=hEndQLvsCH7GgQPEqyqXcsG9CaP9evYFh4Itv0xZLfedOAxSu3MOQI57RzUHeon3Z/ /B5TPLCCY04MxSTZfaFuu3GwnpdPsvMkXXIltbT7aaAuQwDcL7sTYMzvrnd1t8SuJ8b5 rd6sRHEYdUb2YaH5sDay/C/BfBfxG7zd6g+wMbqe+xnxyzAJ8wAxiA2g5wTEnZ2sWlH2 YZ13Rd5lYJUt4ejibwjJD8Xvjd7Zk+Px1dD483v2c0nZml1ZBGnOc0lE4mMDRcIwGWX9 +4W/mI2g49jKraok+ikkon1CrHNVak1JgVFBmP3MX+ERdtj/Zfi8ckJaYQlCxGVoplFH itcQ== 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 y1si5209096edt.101.2020.07.27.04.11.10; Mon, 27 Jul 2020 04:11:32 -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 S1728689AbgG0LHo (ORCPT + 99 others); Mon, 27 Jul 2020 07:07:44 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:40707 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728532AbgG0LGR (ORCPT ); Mon, 27 Jul 2020 07:06:17 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 27 Jul 2020 14:06:13 +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 06RB6DXB022246; Mon, 27 Jul 2020 14:06:13 +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 06RB6D2L002402; Mon, 27 Jul 2020 14:06:13 +0300 Received: (from moshe@localhost) by dev-l-vrt-135.mtl.labs.mlnx (8.15.2/8.15.2/Submit) id 06RB6Dh9002401; Mon, 27 Jul 2020 14:06:13 +0300 From: Moshe Shemesh To: "David S. Miller" , Jiri Pirko , Vasundhara Volam Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Moshe Shemesh Subject: [PATCH net-next RFC 10/13] net/mlx5: Add devlink param enable_remote_dev_reset support Date: Mon, 27 Jul 2020 14:02:30 +0300 Message-Id: <1595847753-2234-11-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1595847753-2234-1-git-send-email-moshe@mellanox.com> References: <1595847753-2234-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 --- .../net/ethernet/mellanox/mlx5/core/devlink.c | 29 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/fw_reset.c | 12 ++++++++ include/linux/mlx5/driver.h | 1 + 3 files changed, 42 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 905d55cab4c3..a81204b3dd7c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -275,6 +275,32 @@ 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); + struct mlx5_core_health *health; + + health = &dev->priv.health; + if (ctx->val.vbool) + clear_bit(MLX5_HEALTH_RESET_FLAGS_NACK_RESET_REQUEST, &health->reset_flags); + else + set_bit(MLX5_HEALTH_RESET_FLAGS_NACK_RESET_REQUEST, &health->reset_flags); + 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); + struct mlx5_core_health *health; + + health = &dev->priv.health; + ctx->val.vbool = !test_bit(MLX5_HEALTH_RESET_FLAGS_NACK_RESET_REQUEST, + &health->reset_flags); + 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, @@ -290,6 +316,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 f95df226b915..45fdecbadf52 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -61,12 +61,24 @@ 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_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_HEALTH_RESET_FLAGS_NACK_RESET_REQUEST, &dev->priv.health.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_health_set_reset_requested_mode(dev); mlx5_reload_health_poll_timer(dev); if (mlx5_fw_set_reset_sync_ack(dev)) diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 27b6086f3095..4999dff9dc8c 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -426,6 +426,7 @@ struct mlx5_sq_bfreg { enum { MLX5_HEALTH_RESET_FLAGS_RESET_REQUESTED, MLX5_HEALTH_RESET_FLAGS_SILENT_RECOVERY, + MLX5_HEALTH_RESET_FLAGS_NACK_RESET_REQUEST, }; struct mlx5_core_health { -- 2.17.1