From patchwork Thu Jul 7 18:29:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikas Gupta X-Patchwork-Id: 12910064 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B3C8C43334 for ; Thu, 7 Jul 2022 18:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236633AbiGGSdO (ORCPT ); Thu, 7 Jul 2022 14:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236816AbiGGScl (ORCPT ); Thu, 7 Jul 2022 14:32:41 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C35D24091 for ; Thu, 7 Jul 2022 11:30:33 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id s206so20046103pgs.3 for ; Thu, 07 Jul 2022 11:30:33 -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=RJb9bY+p1pkuLZT8P6rBdgbRULBMWYdrnofGpWdU5JY=; b=M69FLUcu5Rzf7eQZtnrHf07E8wv07Vkw3GAoL+9/gCCm3PxT8/RxzziV88G/2t4qUt KkOoH++pEDYE4JI2U5ygxzbuVu/lx1e27H65MpZs7oSCoVd0ATFj5/nhJURq8yfOVg94 gBmn/2MQ//ZNrIND5CrdfPwLeK2veCaHDoGNw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RJb9bY+p1pkuLZT8P6rBdgbRULBMWYdrnofGpWdU5JY=; b=FpY1tZ48UPSMbroPpqCG4J6FzP1GbrGAr83hINLIiybpUSBhY625jcWD3f/nZ8IVmi HafOE/c+VR0Qeif+cs9yA9WT/znF9reqRHVDcGtncf/hDOQ6EFOtpZ6FM47CJfJ/Q4ab IFsMtdhJ/G0qDv8VeJvBbzRU9Ui6/P3aIV6X/WiTnoOWtEBeUhov1gIdJiTWDA7jxcbo kK2TtZh7g0bcahy99OVnPavVIyojEEuDuRAYlGBi9d+sE0AjujN+7Que5ySC421ZKZP/ VaNtRkMZMR+Bts9ibM/QI80936vfA/ah6VSZuk2XUkAWbAIJg/5LGcbxdmsyitodP5WR tZwQ== X-Gm-Message-State: AJIora8jfhdkuTfQ2VdE7z/AizO5YYPLTkWn25xbQwNd7pzQBe2T1fBd rAvCdCH9Xou8Hl+Ffqg+L6HTRA== X-Google-Smtp-Source: AGRyM1vkImAooEgYbw8Eu/32MDbRgX997w9QO1uZusEoQdHWIbEae5g2OIk1B7ZF3UUJf88LfmDvmA== X-Received: by 2002:a17:903:40c9:b0:16a:2d26:5553 with SMTP id t9-20020a17090340c900b0016a2d265553mr53925758pld.31.1657218630885; Thu, 07 Jul 2022 11:30:30 -0700 (PDT) Received: from rahul_yocto_ubuntu18.ibn.broadcom.net ([192.19.252.250]) by smtp.gmail.com with ESMTPSA id pj9-20020a17090b4f4900b001ef92e0e7c1sm7132234pjb.10.2022.07.07.11.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 11:30:30 -0700 (PDT) From: Vikas Gupta To: jiri@nvidia.com, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, dsahern@kernel.org, stephen@networkplumber.org, edumazet@google.com, pabeni@redhat.com, ast@kernel.org, leon@kernel.org, linux-doc@vger.kernel.org, corbet@lwn.net, michael.chan@broadcom.com, andrew.gospodarek@broadcom.com, Vikas Gupta Subject: [PATCH net-next v2 3/3] bnxt_en: implement callbacks for devlink selftests Date: Thu, 7 Jul 2022 23:59:50 +0530 Message-Id: <20220707182950.29348-4-vikas.gupta@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220707182950.29348-1-vikas.gupta@broadcom.com> References: <20220628164241.44360-1-vikas.gupta@broadcom.com> <20220707182950.29348-1-vikas.gupta@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add callbacks ============= .selftests_show: populates flash test name. .selftests_run: implements a flash selftest. Signed-off-by: Vikas Gupta Reviewed-by: Michael Chan Reviewed-by: Andy Gospodarek --- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index 3528ce9849e6..750034b45049 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -20,6 +20,8 @@ #include "bnxt_ulp.h" #include "bnxt_ptp.h" #include "bnxt_coredump.h" +#include "bnxt_nvm_defs.h" +#include "bnxt_ethtool.h" static void __bnxt_fw_recover(struct bnxt *bp) { @@ -610,6 +612,63 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti return rc; } +static bool bnxt_nvm_test(struct bnxt *bp, struct netlink_ext_ack *extack) +{ + u32 datalen; + u16 index; + u8 *buf; + + if (bnxt_find_nvram_item(bp->dev, BNX_DIR_TYPE_VPD, + BNX_DIR_ORDINAL_FIRST, BNX_DIR_EXT_NONE, + &index, NULL, &datalen) || !datalen) { + NL_SET_ERR_MSG_MOD(extack, "nvm test vpd entry error"); + return false; + } + + buf = kzalloc(datalen, GFP_KERNEL); + if (!buf) { + NL_SET_ERR_MSG_MOD(extack, "insufficient memory for nvm test"); + return false; + } + + if (bnxt_get_nvram_item(bp->dev, index, 0, datalen, buf)) { + NL_SET_ERR_MSG_MOD(extack, "nvm test vpd read error"); + goto err; + } + + if (bnxt_flash_nvram(bp->dev, BNX_DIR_TYPE_VPD, BNX_DIR_ORDINAL_FIRST, + BNX_DIR_EXT_NONE, 0, 0, buf, datalen)) { + NL_SET_ERR_MSG_MOD(extack, "nvm test vpd write error"); + goto err; + } + + return true; + +err: + kfree(buf); + return false; +} + +static u32 bnxt_dl_selftests_show(struct devlink *dl, + struct netlink_ext_ack *extack) +{ + return DEVLINK_SELFTEST_FLASH; +} + +static void bnxt_dl_selftests_run(struct devlink *dl, u32 test_mask, + u8 *results, struct netlink_ext_ack *extack) +{ + struct bnxt *bp = bnxt_get_bp_from_dl(dl); + bool res; + + if (test_mask & DEVLINK_SELFTEST_FLASH) { + res = bnxt_nvm_test(bp, extack); + results[DEVLINK_SELFTEST_FLASH_BIT] = res ? + DEVLINK_SELFTEST_PASS : + DEVLINK_SELFTEST_FAIL; + } +} + static const struct devlink_ops bnxt_dl_ops = { #ifdef CONFIG_BNXT_SRIOV .eswitch_mode_set = bnxt_dl_eswitch_mode_set, @@ -622,6 +681,8 @@ static const struct devlink_ops bnxt_dl_ops = { .reload_limits = BIT(DEVLINK_RELOAD_LIMIT_NO_RESET), .reload_down = bnxt_dl_reload_down, .reload_up = bnxt_dl_reload_up, + .selftests_show = bnxt_dl_selftests_show, + .selftests_run = bnxt_dl_selftests_run, }; static const struct devlink_ops bnxt_vf_dl_ops;