From patchwork Fri Oct 29 07:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12591973 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13342C433EF for ; Fri, 29 Oct 2021 07:49:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0615604DC for ; Fri, 29 Oct 2021 07:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232390AbhJ2Hv2 (ORCPT ); Fri, 29 Oct 2021 03:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbhJ2Hu7 (ORCPT ); Fri, 29 Oct 2021 03:50:59 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B42AC061570 for ; Fri, 29 Oct 2021 00:48:31 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id y1so6279221plk.10 for ; Fri, 29 Oct 2021 00:48:31 -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=ISnE8uk1b5JbBvt5p0DC+XPNab5hr1XzUdMTV1+QmSU=; b=hNw2W/cDbHNYRJWUNnHQ7TozrQvLOoNKiKYNoLuKj9GTRRbnNDYv3frvtbkqEbtAA9 L2skiFc3a5nXnn4nX52IofwcfLIl7q6/0gbHvJhjDgxOmcBZjX9QAjsz9HK2DFPqGyKV 0nEfvFJXmhdPxCIN3SH6xibabU8+T1F30WQvI= 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=ISnE8uk1b5JbBvt5p0DC+XPNab5hr1XzUdMTV1+QmSU=; b=p6hECTDW8pz883+Q0lGoDP25dm8pjRzOV55Y3FgYQq3/XSRm6Tji/E2SNaN1jGyRTS CnaDZsH1B+tyja790P/XrhobsjjH/hXJyAJhbnjSSuJAHB/mEvxYaFEZIMr2jMuz1tfP ntZrZYmXIEevap/LIykSXEoUW1W6jZnOCxT8FkmNbY42RzWlryXrVE7UY1IgDD/451WK kQt/IVSXlCIHesBGYb+pLe5L8jMD1z1ol5E+GIDrI/G5R0rECvSgbPBldKHaGzhf6VXn FRPgvKEGWU03ufYXx9rZCLCan7eFbe5gFIfkpZLXAS/dyOkhEraBFDJh9VKX/VQWVfLm iF/w== X-Gm-Message-State: AOAM532oQlaGuMLpZmWGpLnXlFp6cKXg6siMu7PHOn6/Zf13WXc+55Q4 Jk2rWuDsbgr61nx1Ap5om7Abww== X-Google-Smtp-Source: ABdhPJwRxH7ClZo5GfaJbVsSUEC2G0oroEtiTSwkHrj8cbt5P6lBj7HQlE0hfmD9V9683+wKongVGQ== X-Received: by 2002:a17:902:c40f:b0:140:6774:9365 with SMTP id k15-20020a170902c40f00b0014067749365mr8592881plk.67.1635493710298; Fri, 29 Oct 2021 00:48:30 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s18sm5721186pfc.87.2021.10.29.00.48.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Oct 2021 00:48:29 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, edwin.peer@broadcom.com, gospo@broadcom.com, jiri@nvidia.com Subject: [PATCH net-next v2 15/19] bnxt_en: implement dump callback for fw health reporter Date: Fri, 29 Oct 2021 03:47:52 -0400 Message-Id: <1635493676-10767-16-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635493676-10767-1-git-send-email-michael.chan@broadcom.com> References: <1635493676-10767-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: Edwin Peer Populate the dump with firmware 'live' coredump data. This includes the information stored in NVRAM by the firmware exception handler prior to recovery. Thus, the live dump includes the desired crash context. Firmware does not support HWRM calls after RESET_NOTIFY, so there is no supported way to capture a coredump during the auto dump phase. Detect this and abort when called from devlink_health_report(). Signed-off-by: Edwin Peer Signed-off-by: Michael Chan --- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index 930cbf1ca4e0..106f4249e47b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -18,6 +18,7 @@ #include "bnxt_ethtool.h" #include "bnxt_ulp.h" #include "bnxt_ptp.h" +#include "bnxt_coredump.h" static void __bnxt_fw_recover(struct bnxt *bp) { @@ -177,6 +178,46 @@ static int bnxt_fw_diagnose(struct devlink_health_reporter *reporter, return devlink_fmsg_u32_pair_put(fmsg, "Diagnoses", h->diagnoses); } +static int bnxt_fw_dump(struct devlink_health_reporter *reporter, + struct devlink_fmsg *fmsg, void *priv_ctx, + struct netlink_ext_ack *extack) +{ + struct bnxt *bp = devlink_health_reporter_priv(reporter); + u32 dump_len; + void *data; + int rc; + + /* TODO: no firmware dump support in devlink_health_report() context */ + if (priv_ctx) + return -EOPNOTSUPP; + + dump_len = bnxt_get_coredump_length(bp, BNXT_DUMP_LIVE); + if (!dump_len) + return -EIO; + + data = vmalloc(dump_len); + if (!data) + return -ENOMEM; + + rc = bnxt_get_coredump(bp, BNXT_DUMP_LIVE, data, &dump_len); + if (!rc) { + rc = devlink_fmsg_pair_nest_start(fmsg, "core"); + if (rc) + goto exit; + rc = devlink_fmsg_binary_pair_put(fmsg, "data", data, dump_len); + if (rc) + goto exit; + rc = devlink_fmsg_u32_pair_put(fmsg, "size", dump_len); + if (rc) + goto exit; + rc = devlink_fmsg_pair_nest_end(fmsg); + } + +exit: + vfree(data); + return rc; +} + static int bnxt_fw_recover(struct devlink_health_reporter *reporter, void *priv_ctx, struct netlink_ext_ack *extack) @@ -195,6 +236,7 @@ static int bnxt_fw_recover(struct devlink_health_reporter *reporter, static const struct devlink_health_reporter_ops bnxt_dl_fw_reporter_ops = { .name = "fw", .diagnose = bnxt_fw_diagnose, + .dump = bnxt_fw_dump, .recover = bnxt_fw_recover, };