From patchwork Tue Jun 28 16:42:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikas Gupta X-Patchwork-Id: 12898568 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 0D99FC433EF for ; Tue, 28 Jun 2022 16:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235920AbiF1QrI (ORCPT ); Tue, 28 Jun 2022 12:47:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232585AbiF1QpS (ORCPT ); Tue, 28 Jun 2022 12:45:18 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DDABDB8 for ; Tue, 28 Jun 2022 09:43:41 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id d17so12492923pfq.9 for ; Tue, 28 Jun 2022 09:43:41 -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=gJYbDrQtsrz10NvJCgg4qlJNoGji+EiG7PVKTBqO3HE=; b=IZVjRlYWh+z+UN55Xz9C+eR/40G/kOJB3q1eyMF8fhs2ZX/QQcN70PqfTturOatmJ0 PkyiUY+oY23ZKbWIOzR7RSVDJqtQmGaTv8oKKbQSpi5CUoSuFvYboZNv+HZihliCXZ1f SH7H/JL2ZeR+MBkMQOmv+fD5SwA53yTQKDe9M= 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=gJYbDrQtsrz10NvJCgg4qlJNoGji+EiG7PVKTBqO3HE=; b=4QlXdXP5T2rodLl4LPaVuLitDg7+MNooGOH5E5KL59HPWpEru/r5MyncTCNZ7O3uyA h4JX4YgSwodzcLskJUEwDBn3toEDI/m/j8NbKWAQxWz56OGR3xPOUwcGj2phTdO5cBc4 vCRuJwu07K0JI38lOZXTn24tYPiv0v2PUviJTWwgh19CP1eZrHjj/9iNBmO0Ht0flq/7 n6KDIrdY8YdKvZsi/kbHA2SM/HT5TFwx3uL/1TME8Zcp3tcNZlXWFw0FskwLmOGR+S/a Ik3XEYRghppUuaj/PXrkAZC7TPmysdalr9H/7SVWu4M6oS+7lI4NJU6rCIcSl+hLHiJm +2cg== X-Gm-Message-State: AJIora9dYlvniiRnBlF+KeHZRtPPG2Rhzf7TCOZIISiJSdaCrh4bqLU4 lnXMxL+PoQCQZtliT3UMRHELFg== X-Google-Smtp-Source: AGRyM1uNdejCd65WOzIt0ueML3WG9HUWGUiNllUk+OIAnoHBv+m+SWGXPG0YwH/Yp9G4680cQYjACA== X-Received: by 2002:a05:6a00:2292:b0:525:6c57:8dd5 with SMTP id f18-20020a056a00229200b005256c578dd5mr4445514pfe.17.1656434621014; Tue, 28 Jun 2022 09:43:41 -0700 (PDT) Received: from rahul_yocto_ubuntu18.ibn.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id mn9-20020a17090b188900b001ec9d45776bsm38248pjb.42.2022.06.28.09.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 09:43:40 -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, michael.chan@broadcom.com, andrew.gospodarek@broadcom.com, Vikas Gupta Subject: [PATCH net-next v1 3/3] bnxt_en: implement callbacks for devlink selftests Date: Tue, 28 Jun 2022 22:12:41 +0530 Message-Id: <20220628164241.44360-4-vikas.gupta@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220628164241.44360-1-vikas.gupta@broadcom.com> References: <20220628164241.44360-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 | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index 3528ce9849e6..232e9b1ff1a9 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,67 @@ 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, "not sufficient 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 int bnxt_dl_selftests_show(struct devlink *dl, struct sk_buff *msg, + struct netlink_ext_ack *extack) +{ + return devlink_selftest_name_put(msg, DEVLINK_SELFTEST_FLASH_TEST_NAME); +} + +static int bnxt_dl_selftests_run(struct devlink *dl, struct sk_buff *msg, + u32 test_mask, struct netlink_ext_ack *extack) +{ + struct bnxt *bp = bnxt_get_bp_from_dl(dl); + struct devlink_selftest_exec_info test; + int rc; + + if (test_mask & DEVLINK_SELFTEST_FLASH) { + test.name = DEVLINK_SELFTEST_FLASH_TEST_NAME; + test.result = bnxt_nvm_test(bp, extack); + rc = devlink_selftest_result_put(msg, &test); + if (rc) + return rc; + } + + return 0; +} + static const struct devlink_ops bnxt_dl_ops = { #ifdef CONFIG_BNXT_SRIOV .eswitch_mode_set = bnxt_dl_eswitch_mode_set, @@ -622,6 +685,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; @@ -1091,6 +1156,7 @@ static int bnxt_dl_nvm_param_set(struct devlink *dl, u32 id, return bnxt_hwrm_nvm_req(bp, id, req, &ctx->val); } + static int bnxt_dl_msix_validate(struct devlink *dl, u32 id, union devlink_param_value val, struct netlink_ext_ack *extack)