From patchwork Sun Oct 11 10:22:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 288611 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, 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 6C3CFC433DF for ; Sun, 11 Oct 2020 10:23:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31668207F7 for ; Sun, 11 Oct 2020 10:23:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="UMLbOUmY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729671AbgJKKXg (ORCPT ); Sun, 11 Oct 2020 06:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729631AbgJKKX3 (ORCPT ); Sun, 11 Oct 2020 06:23:29 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7F53C0613D2 for ; Sun, 11 Oct 2020 03:23:28 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id o3so1229497pgr.11 for ; Sun, 11 Oct 2020 03:23: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=9mj0libdtn4DjGlhqdg+VrW4jvFWBMOCt7yJVWC7hWQ=; b=UMLbOUmYZwVGPv0n8OrcFLTfHWWpcuGzurh323vgvWd9uJAV/strtsr/OUwHVY6PVL be+QQRisMWTUd7AHRQjjFFW3m/OkaNovv+OYLdvHgVNcceP+uYrvgORRIRxGUGqu7zE+ OmyuFzq14+eLFNAUbSRjcyBWIdNMalWQ4veOU= 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=9mj0libdtn4DjGlhqdg+VrW4jvFWBMOCt7yJVWC7hWQ=; b=qmh9CUKnPfvzRzAtAFH4PcgO0vlb1a+NmvHhGmiwvExgO3ErtTtZZyFs38EPpgsBCW ayANoefRzeaPhKk0qM8PnJcgKLk2mr9dDqWfHiywvncFDYJhIANLm5Ktu8lp6/PZF32j OpEgq3BXXoHZ9jqaBfoVeXTbz3MLu8eJ2+mXk8AnygtoC8WLXZ9wUap99aFbJCUNlNm/ D6ohJOYXIvF76ml6drsy96s63no/zjlOPjFxttmwKw7DSE9etJG5BZbEuGwXW1nMnWeg KtKA84XkID58KzY48i8wAAVO2gMG7KwZwYC9IAHzyRmp20Dw6QorUipwp2f+SkIyRUGE lqbQ== X-Gm-Message-State: AOAM533DjzX1ebsrR9FSLupcT7voWsivIrYhcE0DejiAxjkXTCL5Md2T O6dupDhgS/rEcDtXP3OpogbUJwokIB7NNA== X-Google-Smtp-Source: ABdhPJxyJo2ErydNA0f7gBbmiVybMM+us27YTsjFicIKXW+VCWJi4qkjAR2YqOmfJiP7OsbsgCTWxg== X-Received: by 2002:aa7:9f0f:0:b029:155:ef07:6ae0 with SMTP id g15-20020aa79f0f0000b0290155ef076ae0mr2710348pfr.70.1602411808089; Sun, 11 Oct 2020 03:23:28 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i1sm20155057pjh.52.2020.10.11.03.23.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Oct 2020 03:23:27 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com, Vasundhara Volam Subject: [PATCH net-next 7/9] bnxt_en: Add bnxt_hwrm_nvm_get_dev_info() to query NVM info. Date: Sun, 11 Oct 2020 06:22:59 -0400 Message-Id: <1602411781-6012-8-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602411781-6012-1-git-send-email-michael.chan@broadcom.com> References: <1602411781-6012-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vasundhara Volam Add a new bnxt_hwrm_nvm_get_dev_info() to query firmware version information via NVM_GET_DEV_INFO firmware command. Use it to get the running version of the NVM configuration information. This new function will also be used in subsequent patches to get the stored firmware versions. Reviewed-by: Andy Gospodarek Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 16 ++++++++++++++++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 2 ++ 4 files changed, 31 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 2d6ecf1adbc5..55d96e3a69da 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7562,6 +7562,16 @@ static int bnxt_hwrm_func_reset(struct bnxt *bp) return hwrm_send_message(bp, &req, sizeof(req), HWRM_RESET_TIMEOUT); } +static void bnxt_nvm_cfg_ver_get(struct bnxt *bp) +{ + struct hwrm_nvm_get_dev_info_output nvm_info; + + if (!bnxt_hwrm_nvm_get_dev_info(bp, &nvm_info)) + snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", + nvm_info.nvm_cfg_ver_maj, nvm_info.nvm_cfg_ver_min, + nvm_info.nvm_cfg_ver_upd); +} + static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) { int rc = 0; @@ -11223,6 +11233,8 @@ static int bnxt_fw_init_one_p1(struct bnxt *bp) if (rc) return rc; } + bnxt_nvm_cfg_ver_get(bp); + rc = bnxt_hwrm_func_reset(bp); if (rc) return -ENODEV; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index b208ff7c5d14..21ef1c21f602 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1856,6 +1856,7 @@ struct bnxt { #define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN) char fw_ver_str[FW_VER_STR_LEN]; char hwrm_ver_supp[FW_VER_STR_LEN]; + char nvm_cfg_ver[FW_VER_STR_LEN]; u64 fw_ver_code; #define BNXT_FW_VER_CODE(maj, min, bld, rsv) \ ((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv)) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index dcbb7b70d60a..53687bc7fcf5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -2072,6 +2072,22 @@ static u32 bnxt_get_link(struct net_device *dev) return bp->link_info.link_up; } +int bnxt_hwrm_nvm_get_dev_info(struct bnxt *bp, + struct hwrm_nvm_get_dev_info_output *nvm_dev_info) +{ + struct hwrm_nvm_get_dev_info_output *resp = bp->hwrm_cmd_resp_addr; + struct hwrm_nvm_get_dev_info_input req = {0}; + int rc; + + bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_DEV_INFO, -1, -1); + mutex_lock(&bp->hwrm_cmd_lock); + rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); + if (!rc) + memcpy(nvm_dev_info, resp, sizeof(*resp)); + mutex_unlock(&bp->hwrm_cmd_lock); + return rc; +} + static void bnxt_print_admin_err(struct bnxt *bp) { netdev_info(bp->dev, "PF does not have admin privileges to flash or reset the device\n"); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h index 34f44ddfad79..fa6fbde52bea 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h @@ -92,6 +92,8 @@ u32 bnxt_get_rxfh_indir_size(struct net_device *dev); u32 _bnxt_fw_to_ethtool_adv_spds(u16, u8); u32 bnxt_fw_to_ethtool_speed(u16); u16 bnxt_get_fw_auto_link_speeds(u32); +int bnxt_hwrm_nvm_get_dev_info(struct bnxt *bp, + struct hwrm_nvm_get_dev_info_output *nvm_dev_info); int bnxt_flash_package_from_file(struct net_device *dev, const char *filename, u32 install_type); void bnxt_ethtool_init(struct bnxt *bp);