From patchwork Sun May 31 07:03:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasundhara Volam X-Patchwork-Id: 218110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DA50C433DF for ; Sun, 31 May 2020 07:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04C93207D5 for ; Sun, 31 May 2020 07:06:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Yf6/FCO3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729651AbgEaHG3 (ORCPT ); Sun, 31 May 2020 03:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbgEaHG2 (ORCPT ); Sun, 31 May 2020 03:06:28 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89F01C05BD43 for ; Sun, 31 May 2020 00:06:28 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x13so8250004wrv.4 for ; Sun, 31 May 2020 00:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zumKQmkO5e51NlQ/XewW19Eiw2uayLN6M0XGpwmfyZc=; b=Yf6/FCO3FFczNBrDKZreRpHjMqUc/1BLP2W2n3uAhiowl7ipkDpQxwaJ7CF1XWYuYH w/mNzBaCa/VGXnoK0ODOUr6zakA26FGKcxlrZXi+Wj67AwHItUWnG1bq740H1aE92rEf kgdD+nMzhdI6MeXfQuYX9rg6sf7yy0OfSHDWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zumKQmkO5e51NlQ/XewW19Eiw2uayLN6M0XGpwmfyZc=; b=PaKxI8hCMjmfYZtP1jBR5uzcBX/0TGXbDUtMsHhPqS8Au3nXCxi5S3YqgXM1daNNF/ bVps17ftrocBOptEQbH+in4hXPQ3eGhefKCXlvmOVs7jpzwGTZkV9IVuZJnClmvukDO6 r8zNK6Q7F11Cmz1MsEGm5LPZbbDN86ujLt2XC2DUsjI4NDupRpL9sUJgWYeED/aZJVJD q+n+j2CAT9xWyOsj+JM8wVnX/mSNJ0Xq6xRUZGQjqkCXJmZj5F/tQWshYACL6ie3FHgY dvPN/TWQa0N6RdicBWmbkEir4ensSlWjEWsfEQY6IomnZAhwFFQWc0G0abB9MWElwywR HuNA== X-Gm-Message-State: AOAM532XNEs/U7szqkcFQRzsgzCMEqS6DmK9cAhma4VYuKcua7Q+44Xy hzeIHI7tSg7qeSNUPjOd/4R0xQ== X-Google-Smtp-Source: ABdhPJzHcke0YT7pAEnmk2CrTzUFGHiXMApfP/a6kyNecRFlvrEQmBt+kjIq1XJqcTYC9z5pU7iTwg== X-Received: by 2002:a5d:5261:: with SMTP id l1mr16759126wrc.246.1590908787118; Sun, 31 May 2020 00:06:27 -0700 (PDT) Received: from lxpurley1.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 5sm4828731wrr.5.2020.05.31.00.06.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 May 2020 00:06:26 -0700 (PDT) From: Vasundhara Volam To: davem@davemloft.net Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, Vasundhara Volam , Jiri Pirko , Jakub Kicinski Subject: [PATCH v3 net-next 1/6] devlink: Add 'enable_live_dev_reset' generic parameter. Date: Sun, 31 May 2020 12:33:40 +0530 Message-Id: <1590908625-10952-2-git-send-email-vasundhara-v.volam@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com> References: <1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This parameter controls the device's live reset capability. When enabled, a user can issue a separate command like 'ethtool --reset' or 'devlink dev reload' to reset the entire device in real time. This parameter can be useful, if the user wants to upgrade the firmware quickly with a momentary network outage. For example, if a user flashes a new firmware image and if this parameter is enabled, the user can immediately initiate reset of the device, to load the new firmware without reloading the driver manually or resetting the system. Cc: Jiri Pirko Cc: Jakub Kicinski Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- Documentation/networking/devlink/devlink-params.rst | 8 ++++++++ include/net/devlink.h | 4 ++++ net/core/devlink.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst index d075fd0..8e12c83 100644 --- a/Documentation/networking/devlink/devlink-params.rst +++ b/Documentation/networking/devlink/devlink-params.rst @@ -108,3 +108,11 @@ own name. * - ``region_snapshot_enable`` - Boolean - Enable capture of ``devlink-region`` snapshots. + * - ``enable_live_dev_reset`` + - Boolean + - Controls the device's live reset capability. When the parameter is true, + the user can use a separate command to reset the entire device in real + time, that resets the firmware and driver entities. + For example, after flashing a new firmware image, this feature allows the + user to initiate the reset immediately from a separate command, to load + the new firmware without reloading the driver or resetting the system. diff --git a/include/net/devlink.h b/include/net/devlink.h index 8ffc1b5c..eb28fa1 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -406,6 +406,7 @@ enum devlink_param_generic_id { DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY, DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE, DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, + DEVLINK_PARAM_GENERIC_ID_ENABLE_LIVE_DEV_RESET, /* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX, @@ -443,6 +444,9 @@ enum devlink_param_generic_id { #define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME "enable_roce" #define DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE DEVLINK_PARAM_TYPE_BOOL +#define DEVLINK_PARAM_GENERIC_ENABLE_LIVE_DEV_RESET_NAME "enable_live_dev_reset" +#define DEVLINK_PARAM_GENERIC_ENABLE_LIVE_DEV_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL + #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ diff --git a/net/core/devlink.c b/net/core/devlink.c index 7b76e5f..7b52b38 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -3011,6 +3011,11 @@ static int devlink_nl_cmd_flash_update(struct sk_buff *skb, .name = DEVLINK_PARAM_GENERIC_ENABLE_ROCE_NAME, .type = DEVLINK_PARAM_GENERIC_ENABLE_ROCE_TYPE, }, + { + .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_LIVE_DEV_RESET, + .name = DEVLINK_PARAM_GENERIC_ENABLE_LIVE_DEV_RESET_NAME, + .type = DEVLINK_PARAM_GENERIC_ENABLE_LIVE_DEV_RESET_TYPE, + }, }; static int devlink_param_generic_verify(const struct devlink_param *param) From patchwork Sun May 31 07:03:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasundhara Volam X-Patchwork-Id: 218109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 919A3C433DF for ; Sun, 31 May 2020 07:06:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B3A3207BC for ; Sun, 31 May 2020 07:06:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QqKi83xe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387414AbgEaHGr (ORCPT ); Sun, 31 May 2020 03:06:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387407AbgEaHGr (ORCPT ); Sun, 31 May 2020 03:06:47 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0637EC05BD43 for ; Sun, 31 May 2020 00:06:47 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id r7so8301130wro.1 for ; Sun, 31 May 2020 00:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=28iXEgTxZGiycTdVsy4Tz/mI6Y6DSr8IpzNq47taE6U=; b=QqKi83xeAVIB3Rk4gVswD+kmoCTWZRuU7Lu6+j07fwz2M28nBhd6Hc3QTTOOonKGCT 1VqlWuHexs8AwTWIwnKXeQQYTyhpQgalQD+5YXjuZy8LwlfJgZgTPVCf1LzAJNEVhhPI yvFaqJN0jt8yrhNhzfXzR0TJX1ULzmARbY1UA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=28iXEgTxZGiycTdVsy4Tz/mI6Y6DSr8IpzNq47taE6U=; b=St2cisqtfmjzEMz29p2RkuukRetzuGkQEQ6IA6YTs+m06JDdLF8YZSl1plbhrPENF/ SppCKkHm2C2JqI3lixhZYcO87wWI7Y6siV7YEsgmKAXsHm6aWoPiQ7YO5zC8kJdxr8JK ZgKCkQV93BNBQ0xbDQ3jSWQFAFIQuXILLAgAI3rjWWCre2NN2uROgQ9M4bUp0/Y0IXW3 BP4HH+Usfp1+Vq4pwzjuHiO7YdpmZcSWihKhHKuwKCvyGb2WNtTt7g1WLl7FR3HENIeE 1iq29ZxW9uKt3AW0Db6cRHjhAInru1CVksaxg+OIEBui8e1LNhBobBDGqs+mXm7Kxzzc y1hg== X-Gm-Message-State: AOAM5302l1gzgTl1554Za8lf8ItOX4Jqc07P9cxujcfxnI1iTjF6Nqt/ VPmSPmQgzPFnsKg976YvPcCEVNSqBoo= X-Google-Smtp-Source: ABdhPJwhlRVmuv0eGYBQFMy9+EyETPpK00ik/ueqcyTpRWYPuVBifVtW7eXqsTj+KG2D/6vXvwUFTQ== X-Received: by 2002:a05:6000:1c8:: with SMTP id t8mr16214736wrx.200.1590908805631; Sun, 31 May 2020 00:06:45 -0700 (PDT) Received: from lxpurley1.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 5sm4828731wrr.5.2020.05.31.00.06.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 May 2020 00:06:45 -0700 (PDT) From: Vasundhara Volam To: davem@davemloft.net Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, Vasundhara Volam Subject: [PATCH v3 net-next 3/6] bnxt_en: Use 'enable_live_dev_reset' devlink parameter. Date: Sun, 31 May 2020 12:33:42 +0530 Message-Id: <1590908625-10952-4-git-send-email-vasundhara-v.volam@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com> References: <1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When enabled, device will enable the live reset capability in NVRAM configuration. Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- Documentation/networking/devlink/bnxt.rst | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 6 ++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 1 + 3 files changed, 9 insertions(+) diff --git a/Documentation/networking/devlink/bnxt.rst b/Documentation/networking/devlink/bnxt.rst index 3dfd84c..ae0a69d 100644 --- a/Documentation/networking/devlink/bnxt.rst +++ b/Documentation/networking/devlink/bnxt.rst @@ -22,6 +22,8 @@ Parameters - Permanent * - ``msix_vec_per_pf_min`` - Permanent + * - ``enable_live_dev_reset`` + - Permanent The ``bnxt`` driver also implements the following driver-specific parameters. diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index a812beb..3e1a4ef 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -314,6 +314,8 @@ enum bnxt_dl_param_id { NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7, 4}, {BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK, BNXT_NVM_SHARED_CFG, 1, 1}, + {DEVLINK_PARAM_GENERIC_ID_ENABLE_LIVE_DEV_RESET, + NVM_OFF_FW_LIVE_RESET, BNXT_NVM_SHARED_CFG, 1, 1}, }; union bnxt_nvm_data { @@ -640,6 +642,10 @@ static int bnxt_dl_msix_validate(struct devlink *dl, u32 id, BIT(DEVLINK_PARAM_CMODE_PERMANENT), bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set, NULL), + DEVLINK_PARAM_GENERIC(ENABLE_LIVE_DEV_RESET, + BIT(DEVLINK_PARAM_CMODE_PERMANENT), + bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set, + NULL), }; static const struct devlink_param bnxt_dl_port_params[] = { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h index d5c8bd4..0c786fb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h @@ -39,6 +39,7 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl) #define NVM_OFF_DIS_GRE_VER_CHECK 171 #define NVM_OFF_ENABLE_SRIOV 401 #define NVM_OFF_NVM_CFG_VER 602 +#define NVM_OFF_FW_LIVE_RESET 917 #define BNXT_NVM_CFG_VER_BITS 24 #define BNXT_NVM_CFG_VER_BYTES 4 From patchwork Sun May 31 07:03:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasundhara Volam X-Patchwork-Id: 218108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C001C433DF for ; Sun, 31 May 2020 07:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B0EE207BC for ; Sun, 31 May 2020 07:07:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="iHtqaX4y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387433AbgEaHHA (ORCPT ); Sun, 31 May 2020 03:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387407AbgEaHG7 (ORCPT ); Sun, 31 May 2020 03:06:59 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97AA6C05BD43 for ; Sun, 31 May 2020 00:06:59 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id f185so8238309wmf.3 for ; Sun, 31 May 2020 00:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T2V/Yn57ra8AwU/cESpZtKBEP4Kg27ZBno5kLaCrvLo=; b=iHtqaX4yKGR8EO0AJj10QWDdJ0L+YCSmoQGYdZ6NQz0SgGPmSa6tZhLC8YRCRH9lsL 7b4bkqEL3BDqjm6wcwvLwIeKQbvuz9eJ92y9X2SH1s5UAxy/UWK7iQviaTq8/FZR62gl 5Tfcs05dm+Bg6PvjIxxt3/PA+d6OBxSCAsR/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T2V/Yn57ra8AwU/cESpZtKBEP4Kg27ZBno5kLaCrvLo=; b=eEkdJ+1qQoLUlOEo/0hmsvB9uODiY92YaJS2/7gucH0n1l2aPcqsO2Kh0UcrTyYdqO GycviWIZDaQAObdG2/WOxrTsBeHCF64jAag3ozIIXCAdtvmVyga+Q3naxa8PCD9/ZQtm YXYmR6CMqhGk73Aje/NPiJz8VspfWajPvHSneB04ZdR8xQ2yU53PVPRXCIMwO2aYIEVC /EqVjQpzwKL7u9g7QXj183ADIuOk/wV+yMzpmRQdwok/8qXfzsjtaBCYj9fJKYVwoQgV T35lB3mmQX9LtGdfCPu1An1+xY9KKgDIj/GLfNqwZoPjfKhl0Lyl7WjvvsQkKj9/SSMc cxlg== X-Gm-Message-State: AOAM532nQ7XWq3af4ZcDkwaOH/exus3OvUMojlamgXwcO+ghnDEZoDZr Q2abNCRcHCaTansS8Qw/ywjvDA== X-Google-Smtp-Source: ABdhPJyWxmweHYW45M4KjcCi8VQ4Va8UXAwwLBAll3Cd3uOdEKl+hNBSkJWBDAS6cf/AJmZjE3Eudg== X-Received: by 2002:a7b:c212:: with SMTP id x18mr6980739wmi.119.1590908818127; Sun, 31 May 2020 00:06:58 -0700 (PDT) Received: from lxpurley1.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 5sm4828731wrr.5.2020.05.31.00.06.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 May 2020 00:06:57 -0700 (PDT) From: Vasundhara Volam To: davem@davemloft.net Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, Vasundhara Volam Subject: [PATCH v3 net-next 5/6] bnxt_en: Use 'allow_live_dev_reset' devlink parameter. Date: Sun, 31 May 2020 12:33:44 +0530 Message-Id: <1590908625-10952-6-git-send-email-vasundhara-v.volam@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com> References: <1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This parameter allows the user to prevent live reset of the device temporarily by setting it to false. For example, if the host is running a mission critical application, user can set this parameter to false until the application has completed, to avoid a potential device reset disrupting it. Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- v2->v3: Rename parameter name to "allow_live_dev_reset". - Moved permanent configuration mode code to a separate patch as the param is renamed to "enable_live_dev_reset". - Rename the get/set callbacks of the param accordingly. - Moved the documentation completely to devlink-params.rst file. --- Documentation/networking/devlink/bnxt.rst | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 ++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 43 +++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/devlink/bnxt.rst b/Documentation/networking/devlink/bnxt.rst index ae0a69d..5573663 100644 --- a/Documentation/networking/devlink/bnxt.rst +++ b/Documentation/networking/devlink/bnxt.rst @@ -24,6 +24,8 @@ Parameters - Permanent * - ``enable_live_dev_reset`` - Permanent + * - ``allow_live_dev_reset`` + - Runtime The ``bnxt`` driver also implements the following driver-specific parameters. diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index f86b621..535fe8f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6955,7 +6955,7 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) struct hwrm_func_qcaps_input req = {0}; struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr; struct bnxt_hw_resc *hw_resc = &bp->hw_resc; - u32 flags; + u32 flags, flags_ext; bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCAPS, -1, -1); req.fid = cpu_to_le16(0xffff); @@ -6985,6 +6985,10 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) if (flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED) bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; + flags_ext = le32_to_cpu(resp->flags_ext); + if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_HOT_RESET_IF_SUPPORT) + bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF_SUPPORT; + hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); @@ -8773,6 +8777,28 @@ static int bnxt_hwrm_shutdown_link(struct bnxt *bp) static int bnxt_fw_init_one(struct bnxt *bp); +int bnxt_hwrm_get_hot_reset(struct bnxt *bp, bool *hot_reset_allowed) +{ + struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr; + struct hwrm_func_qcfg_input req = {0}; + int rc; + + if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF_SUPPORT)) { + *hot_reset_allowed = !!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET); + return 0; + } + + bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCFG, -1, -1); + req.fid = cpu_to_le16(0xffff); + mutex_lock(&bp->hwrm_cmd_lock); + rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); + if (!rc) + *hot_reset_allowed = !!(le16_to_cpu(resp->flags) & + FUNC_QCFG_RESP_FLAGS_HOT_RESET_ALLOWED); + mutex_unlock(&bp->hwrm_cmd_lock); + return rc; +} + static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) { struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index c04ac4a..fd6592e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1710,6 +1710,7 @@ struct bnxt { #define BNXT_FW_CAP_ERR_RECOVER_RELOAD 0x00100000 #define BNXT_FW_CAP_HOT_RESET 0x00200000 #define BNXT_FW_CAP_SHARED_PORT_CFG 0x00400000 + #define BNXT_FW_CAP_HOT_RESET_IF_SUPPORT 0x08000000 #define BNXT_NEW_RM(bp) ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM) u32 hwrm_spec_code; @@ -2062,5 +2063,6 @@ int bnxt_get_port_parent_id(struct net_device *dev, struct netdev_phys_item_id *ppid); void bnxt_dim_work(struct work_struct *work); int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi); +int bnxt_hwrm_get_hot_reset(struct bnxt *bp, bool *hot_reset_allowed); #endif diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index 3e1a4ef..da31351 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -620,6 +620,45 @@ static int bnxt_dl_msix_validate(struct devlink *dl, u32 id, return 0; } +static int bnxt_live_dev_reset_get(struct devlink *dl, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct bnxt *bp = bnxt_get_bp_from_dl(dl); + + return bnxt_hwrm_get_hot_reset(bp, &ctx->val.vbool); +} + +static int bnxt_live_dev_reset_set(struct devlink *dl, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct bnxt *bp = bnxt_get_bp_from_dl(dl); + struct hwrm_func_cfg_input req = {0}; + bool hot_reset_allowed; + int rc; + + if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF_SUPPORT)) + return -EOPNOTSUPP; + + bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); + req.fid = cpu_to_le16(0xffff); + req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_HOT_RESET_IF_SUPPORT); + if (ctx->val.vbool) + req.flags = cpu_to_le32(FUNC_CFG_REQ_FLAGS_HOT_RESET_IF_EN_DIS); + + rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); + if (rc) + return rc; + + rc = bnxt_hwrm_get_hot_reset(bp, &hot_reset_allowed); + if (rc) + return rc; + + if (ctx->val.vbool && !hot_reset_allowed) + netdev_info(bp->dev, "Live reset enabled, but is disallowed as it is disabled on other interface(s) of this device.\n"); + + return 0; +} + static const struct devlink_param bnxt_dl_params[] = { DEVLINK_PARAM_GENERIC(ENABLE_SRIOV, BIT(DEVLINK_PARAM_CMODE_PERMANENT), @@ -646,6 +685,10 @@ static int bnxt_dl_msix_validate(struct devlink *dl, u32 id, BIT(DEVLINK_PARAM_CMODE_PERMANENT), bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set, NULL), + DEVLINK_PARAM_GENERIC(ALLOW_LIVE_DEV_RESET, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + bnxt_live_dev_reset_get, bnxt_live_dev_reset_set, + NULL), }; static const struct devlink_param bnxt_dl_port_params[] = {