From patchwork Mon Oct 12 09:10:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 11831987 X-Patchwork-Delegate: kuba@kernel.org 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 76074C43467 for ; Mon, 12 Oct 2020 09:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A16420790 for ; Mon, 12 Oct 2020 09:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gmsr73QM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729379AbgJLJLh (ORCPT ); Mon, 12 Oct 2020 05:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729343AbgJLJL1 (ORCPT ); Mon, 12 Oct 2020 05:11:27 -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 2F07FC0613D2 for ; Mon, 12 Oct 2020 02:11:27 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id n9so13637262pgf.9 for ; Mon, 12 Oct 2020 02:11:27 -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=wKVcZbh83k6X/F14A+ztOkjMdocn7bFn38YmFQmh5vQ=; b=gmsr73QMhy44nj2bUAT5Nu2x64BPwQjJKIgVIdVt0t+0Puc+DBwhg+nUVlg7ejQVeQ oHj9vPjQ2uneN1RI8kymY9G+B/7tpXU1NxarTKjif82tj9rQRL/S2lmetE8Lxg8O68Qr ezRpzMOYDMxZX22wG/jfMbGN4zBQVHXeZx3BU= 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=wKVcZbh83k6X/F14A+ztOkjMdocn7bFn38YmFQmh5vQ=; b=E+AyX7mFuk5aI7aWRr6VHKI9iIFymoVLxWQcc2ws2VMqA2FE63mOGO0Byc8HzU/gc1 Vi34FByUMjH25s2o6XcEmm4MA/pMNY9I6ov2G9cj6RAUKeS/A7VuI71tNnH8bgq5pidw AmVap5B+eCMh7lM/hAYZjNE0jQMR6Ez8mmUuSMSBtW9+Qa/Sh1ZleDRXNzWU3D1bjQtS 81p1bRh1631nPGlhz8ATzZuKB4iwfjNc5IWcO42yctGa7Ykz6ldI2Rb4grNUrgxlB16m Wez4jcYxBUS5ZY6/0nsZYuD7fyzLV9Ocir4pJNMYJuWD33Lk2QhQPuVjagy3HYYnY5eP 3ilg== X-Gm-Message-State: AOAM532sz0rrdUStVf9UHiI8AHZXGSVgXsuHNHbOqR4SXX0dpXMekgPt 2to28uLWm38CtbLcsG2+oXbl/5LgDShkdQ== X-Google-Smtp-Source: ABdhPJy978tl0KNWJ9glZaS9pIMPXOl7V5IExBq5LgvETfdBAkg/9gextptUIFj05UF6ckNwpuwCjw== X-Received: by 2002:a62:ab0e:0:b029:156:1dfe:ae74 with SMTP id p14-20020a62ab0e0000b02901561dfeae74mr3729906pff.7.1602493886539; Mon, 12 Oct 2020 02:11:26 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id jy19sm1275932pjb.9.2020.10.12.02.11.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2020 02:11:25 -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 v2 9/9] bnxt_en: Add stored FW version info to devlink info_get cb. Date: Mon, 12 Oct 2020 05:10:54 -0400 Message-Id: <1602493854-29283-10-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602493854-29283-1-git-send-email-michael.chan@broadcom.com> References: <1602493854-29283-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vasundhara Volam This patch adds FW versions stored in the flash to devlink info_get callback. Return the correct fw.psid running version using the newly added bp->nvm_cfg_ver. v2: Ensure stored pkg_name string is NULL terminated when copied to devlink. Return directly from the last call to bnxt_dl_info_put(). If the FW call to get stored version fails for any reason, return success immediately to devlink without the stored versions. Reviewed-by: Andy Gospodarek Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index 0be9b46baaca..184b6d0513b2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -410,6 +410,7 @@ static int bnxt_dl_info_put(struct bnxt *bp, struct devlink_info_req *req, static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req, struct netlink_ext_ack *extack) { + struct hwrm_nvm_get_dev_info_output nvm_dev_info; struct bnxt *bp = bnxt_get_bp_from_dl(dl); union devlink_param_value nvm_cfg_ver; struct hwrm_ver_get_output *ver_resp; @@ -457,6 +458,12 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req, if (rc) return rc; + rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_PSID, + bp->nvm_cfg_ver); + if (rc) + return rc; + buf[0] = 0; strncat(buf, ver_resp->active_pkg_name, HWRM_FW_VER_STR_LEN); rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, @@ -469,7 +476,7 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req, sprintf(buf, "%X.%X.%X", (ver >> 16) & 0xF, (ver >> 8) & 0xF, ver & 0xF); - rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, + rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, DEVLINK_INFO_VERSION_GENERIC_FW_PSID, buf); if (rc) @@ -517,7 +524,43 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req, if (rc) return rc; - return bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, + rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, + DEVLINK_INFO_VERSION_GENERIC_FW_ROCE, roce_ver); + if (rc) + return rc; + + rc = bnxt_hwrm_nvm_get_dev_info(bp, &nvm_dev_info); + if (rc || + !(nvm_dev_info.flags & NVM_GET_DEV_INFO_RESP_FLAGS_FW_VER_VALID)) + return 0; + + buf[0] = 0; + strncat(buf, nvm_dev_info.pkg_name, HWRM_FW_VER_STR_LEN); + rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, + DEVLINK_INFO_VERSION_GENERIC_FW, buf); + if (rc) + return rc; + + snprintf(mgmt_ver, FW_VER_STR_LEN, "%d.%d.%d.%d", + nvm_dev_info.hwrm_fw_major, nvm_dev_info.hwrm_fw_minor, + nvm_dev_info.hwrm_fw_build, nvm_dev_info.hwrm_fw_patch); + rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, + DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, mgmt_ver); + if (rc) + return rc; + + snprintf(ncsi_ver, FW_VER_STR_LEN, "%d.%d.%d.%d", + nvm_dev_info.mgmt_fw_major, nvm_dev_info.mgmt_fw_minor, + nvm_dev_info.mgmt_fw_build, nvm_dev_info.mgmt_fw_patch); + rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, + DEVLINK_INFO_VERSION_GENERIC_FW_NCSI, ncsi_ver); + if (rc) + return rc; + + snprintf(roce_ver, FW_VER_STR_LEN, "%d.%d.%d.%d", + nvm_dev_info.roce_fw_major, nvm_dev_info.roce_fw_minor, + nvm_dev_info.roce_fw_build, nvm_dev_info.roce_fw_patch); + return bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, DEVLINK_INFO_VERSION_GENERIC_FW_ROCE, roce_ver); }