Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2167128pxa; Mon, 17 Aug 2020 02:42:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoyJdt0Awd0p9qQChOmqQdSngWc2vDfapxnOe/Vo6mv0NIAZiPkhx3/pu4d/1naeNdjXxw X-Received: by 2002:a50:da44:: with SMTP id a4mr14481640edk.36.1597657371961; Mon, 17 Aug 2020 02:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597657371; cv=none; d=google.com; s=arc-20160816; b=Ap+PhrYJeLGRmKSFp54jerDloK13HCA8sgzooAnfjNEaD81CGo4NQpJGXHsV/2lIUB z+oJ3FAH/xk7CanNiZuEVKQBukPimgLXG2AKI4UXnlfiZIHXbeapqqZwf5asUMaq21VC 5sQFoMCwyhMm5xP9Q3feX8qaro9o3mzhYcds6mDDdD9uDAyu041Fbw+zIvCO0VtTLmdU wzzSJCpmL95rPGpHkdSTbDn50HjBogIAC3c3G9XigBuwyqGobz+QfYe02kTa2uXFmHW2 W33sU1ohxQC9fFiyusG2hb17DNABI2/KnYI0lk0Nos61boOx0TfrPkgBPOkYnGDQMTiG mjNg== 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=2UHVZdiN5p/X7AwJmY7SpIxfWUP3ceZjPvjYoqoip54=; b=qHur257wV//Fpkf792GyIeeP/rgJrEh/EIA8yMYK2J3aAA8uYAmjf7xUyiw6ybfXYC Ncpn+iZb+EnH0Qn0jHLUnQ+M+a6eyZqITzWjpn7dDVmzKpqfVYh8qmCbDSlOwMEv8uFV DI2wwTnuCN3I0QxWpn2gbJJG42cuP+0JRUZkAgmfttSaswjw/kb+CBhtYOaFaK9y7dAP 8gj0xaUVrZYkNpxRhIq44BZrV9FghdajwIup/Bd6Hr0y4SsR6Ic834N2nN5cIT9Uyr6X fWOr9ds/iz/Pb2CeO2onwu+8UPBvF/nx9YHAwm7rmENGGZ1lzGTLJT4i+lOHF0i53xPK fyxw== 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 rp21si10884052ejb.0.2020.08.17.02.42.28; Mon, 17 Aug 2020 02:42:51 -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 S1727869AbgHQJju (ORCPT + 99 others); Mon, 17 Aug 2020 05:39:50 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:55861 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728382AbgHQJiR (ORCPT ); Mon, 17 Aug 2020 05:38:17 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 17 Aug 2020 12:38:14 +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 07H9cEpu011437; Mon, 17 Aug 2020 12:38:14 +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 07H9cEUf003250; Mon, 17 Aug 2020 12:38:14 +0300 Received: (from moshe@localhost) by dev-l-vrt-135.mtl.labs.mlnx (8.15.2/8.15.2/Submit) id 07H9cEqU003249; Mon, 17 Aug 2020 12:38:14 +0300 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Jiri Pirko Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Moshe Shemesh Subject: [PATCH net-next RFC v2 12/13] net/mlx5: Add support for devlink reload action live patch Date: Mon, 17 Aug 2020 12:37:51 +0300 Message-Id: <1597657072-3130-13-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1597657072-3130-1-git-send-email-moshe@mellanox.com> References: <1597657072-3130-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 Add support for devlink reload action fw_live_patch which does live patching to firmware. The driver checks if the firmware is capable of handling the pending firmware changes as a live patch. If it is then it triggers fw_live_patch flow. Signed-off-by: Moshe Shemesh --- v1 -> v2: - Have fw_live_patch action instead of level --- .../net/ethernet/mellanox/mlx5/core/devlink.c | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index d975f5bd7394..a62281cfc084 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -115,6 +115,29 @@ static int mlx5_devlink_reload_fw_activate(struct devlink *devlink, struct netli return err; } +static int mlx5_devlink_trigger_fw_live_patch(struct devlink *devlink, + struct netlink_ext_ack *extack) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + u8 reset_level; + int err; + + err = mlx5_reg_mfrl_query(dev, &reset_level, NULL); + if (err) + return err; + if (!(reset_level & MLX5_MFRL_REG_RESET_LEVEL0)) { + NL_SET_ERR_MSG_MOD(extack, + "FW upgrade to the stored FW can't be done by FW live patching"); + return -EINVAL; + } + + err = mlx5_fw_set_live_patch(dev); + if (err) + return err; + + return 0; +} + static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, enum devlink_reload_action action, struct netlink_ext_ack *extack) @@ -127,6 +150,8 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, return 0; case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: return mlx5_devlink_reload_fw_activate(devlink, extack); + case DEVLINK_RELOAD_ACTION_FW_LIVE_PATCH: + return mlx5_devlink_trigger_fw_live_patch(devlink, extack); default: /* Unsupported action should not get to this function */ WARN_ON(1); @@ -143,6 +168,8 @@ static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_a case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: return mlx5_load_one(dev, false); + case DEVLINK_RELOAD_ACTION_FW_LIVE_PATCH: + return 0; default: /* Unsupported action should not get to this function */ WARN_ON(1); @@ -164,7 +191,8 @@ static const struct devlink_ops mlx5_devlink_ops = { .flash_update = mlx5_devlink_flash_update, .info_get = mlx5_devlink_info_get, .supported_reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) | - BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE), + BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE) | + BIT(DEVLINK_RELOAD_ACTION_FW_LIVE_PATCH), .reload_down = mlx5_devlink_reload_down, .reload_up = mlx5_devlink_reload_up, }; -- 2.17.1