Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp882445ybg; Fri, 18 Oct 2019 08:45:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTbEQxh5D0y04GntxxbEWWufpyoOr8tJIgV1cOvICFEut3JuP4JumtpfwpcK94BFRPIGPF X-Received: by 2002:a17:906:4545:: with SMTP id s5mr8931443ejq.223.1571413501832; Fri, 18 Oct 2019 08:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571413501; cv=none; d=google.com; s=arc-20160816; b=a+d2zN5nO3pd8G6Hy5z6VjZQBKDYbOYE5ti2YWSfk3LjJvx66aCbM90GYm6H7pmdnW g9dujFzm6KKDeEoEJvq+Rb4VFUGUoEYzwMvhHcp5v77XIft6Q5R/3rew9CFqCkV/GUoN 0VU/teMAqzy1WrWP4VQ3D0Jr2VDIXA6xHslYiO3iw9aLgmhbvS+puoeewNxiPu6xPX2X gd2C3bpdI5WJT+hbsb5R/e4MpvnR51+nnh244D6lCaHYF98X4qEBohh0kDBdBeRkBVPK u26NpdQgM/6EaO/BoLt9Me18b2ijeuPWYVHFppDpziC/hQMuySikwTHcpHt+4SYes0YL UJ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tX0Ftqak4R2nBwIJhEYcSRn89ISdRNtAIBGqgcMm9qk=; b=UcsA8SjbNlOvSmGBgdPAbWHs4GaEp5x9SnnA/95vHJVn22ecQUt5HSxUct15Vjwqv8 a6DZy6475mbwYm+7tsjQwNGVlx/w3chxaBeParxLVqHbNCmLW4oaHQ3F7xoo9UQNaug7 6I5TgAw0olv1m4Yp+mPt0jmHleb404KPbmZdOBwBooT83eOxqoa+mialsC1F95UVp5WY REa08eW+mKShlWrp7Sudf6IhVdC+f/Auee5/yOwgopO5eWMuT7c/90G3EXErUxUNe4tE 2mEeMH7tLGSlAipfsFZVjMjH1tLQMdn1JKWttkzA7HMDpsRh6eWJfk+eSsVQggTBzoSk L1mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Tqlujk3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14si4074844edt.92.2019.10.18.08.44.38; Fri, 18 Oct 2019 08:45:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Tqlujk3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502255AbfJQMCE (ORCPT + 99 others); Thu, 17 Oct 2019 08:02:04 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34572 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502254AbfJQMBv (ORCPT ); Thu, 17 Oct 2019 08:01:51 -0400 Received: by mail-wm1-f68.google.com with SMTP id y135so6874563wmc.1 for ; Thu, 17 Oct 2019 05:01:48 -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=tX0Ftqak4R2nBwIJhEYcSRn89ISdRNtAIBGqgcMm9qk=; b=Tqlujk3TKIxQUIZQEQPDYzgjH8DnuJg3YtB6UepNiVhCWYfT2x3WcBMnc6H5n8TD2f VyK+xUK6v3ztl59U8d0b2lFLI2UeeQRpkwyEXkNzdDm/mbIb0iazCm5nKausHG8SodMO 85pRPNh3gBWT5kJvYkXRV6U+iyQcO3R806HV4= 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=tX0Ftqak4R2nBwIJhEYcSRn89ISdRNtAIBGqgcMm9qk=; b=MHT3HLDoyAfUM0n4RIdgwaWQkqPthpC60kw5TfYZFmCDGgB8oTPrff0l4Xje1TpEpT bFv1s34HALNfHYJhe1inbl7LRc/XgPzoWhQCOKmHq/YXEahLLD0LZn85sl2+eyaPIn73 x757PNuPzoJm7VtFWzB0dWWsILEBXi8nv8lgR3BFvKAZN95SwJqHUuRp4Hnv4pQsW4Cj WEdYTZxW6KQQQIevJdHhv5iBRXtRVUws30XZMZec3H3K6cOY2a4TD3NHLTR/gHFpoNF+ JZi7v0FnFRNWsv73lilqxw/h1E9xmbtR/AsZPnghH5CaqERlAVJwZ2ZoF/IIU8LfkyuY p0gw== X-Gm-Message-State: APjAAAXhTsYFIqo+Dvg8vbTeL1wsKVNc3xMqpBxS5JkEIdnCH4d+Xv4Z pKAp41o9m+dsECs6XEyefUTYmw== X-Received: by 2002:a05:600c:2481:: with SMTP id 1mr2454420wms.98.1571313707563; Thu, 17 Oct 2019 05:01:47 -0700 (PDT) Received: from shitalt.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y1sm2317949wrw.6.2019.10.17.05.01.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Oct 2019 05:01:45 -0700 (PDT) From: Sheetal Tigadoli To: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Greg Kroah-Hartman , Michal Simek , Rajan Vaja , Scott Branden , Ray Jui , Vikram Prakash , Jens Wiklander , Michael Chan , "David S. Miller" , Vikas Gupta , Vasundhara Volam Cc: Linux Kernel Mailing List , tee-dev@lists.linaro.org, bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, Sheetal Tigadoli Subject: [PATCH V2 3/3] bnxt_en: Add support to collect crash dump via ethtool Date: Thu, 17 Oct 2019 17:31:22 +0530 Message-Id: <1571313682-28900-4-git-send-email-sheetal.tigadoli@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1571313682-28900-1-git-send-email-sheetal.tigadoli@broadcom.com> References: <1571313682-28900-1-git-send-email-sheetal.tigadoli@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vasundhara Volam Driver supports 2 types of core dumps. 1. Live dump - Firmware dump when system is up and running. 2. Crash dump - Dump which is collected during firmware crash that can be retrieved after recovery. Crash dump is currently supported only on specific 58800 chips which can be retrieved using OP-TEE API only, as firmware cannot access this region directly. User needs to set the dump flag using following command before initiating the dump collection: $ ethtool -W|--set-dump eth0 N Where N is "0" for live dump and "1" for crash dump Command to collect the dump after setting the flag: $ ethtool -w eth0 data Filename Cc: Michael Chan Signed-off-by: Vasundhara Volam Signed-off-by: Sheetal Tigadoli --- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 36 +++++++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 2 ++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 0943715..3e7d1fb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1807,6 +1807,9 @@ struct bnxt { u8 num_leds; struct bnxt_led_info leds[BNXT_MAX_LED]; + u16 dump_flag; +#define BNXT_DUMP_LIVE 0 +#define BNXT_DUMP_CRASH 1 struct bpf_prog *xdp_prog; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 51c1404..1596221 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -3311,6 +3311,23 @@ static int bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len) return rc; } +static int bnxt_set_dump(struct net_device *dev, struct ethtool_dump *dump) +{ + struct bnxt *bp = netdev_priv(dev); + +#ifndef CONFIG_TEE_BNXT_FW + return -EOPNOTSUPP; +#endif + + if (dump->flag > BNXT_DUMP_CRASH) { + netdev_err(dev, "Supports only Live(0) and Crash(1) dumps.\n"); + return -EINVAL; + } + + bp->dump_flag = dump->flag; + return 0; +} + static int bnxt_get_dump_flag(struct net_device *dev, struct ethtool_dump *dump) { struct bnxt *bp = netdev_priv(dev); @@ -3323,7 +3340,12 @@ static int bnxt_get_dump_flag(struct net_device *dev, struct ethtool_dump *dump) bp->ver_resp.hwrm_fw_bld_8b << 8 | bp->ver_resp.hwrm_fw_rsvd_8b; - return bnxt_get_coredump(bp, NULL, &dump->len); + dump->flag = bp->dump_flag; + if (bp->dump_flag == BNXT_DUMP_CRASH) + dump->len = BNXT_CRASH_DUMP_LEN; + else + bnxt_get_coredump(bp, NULL, &dump->len); + return 0; } static int bnxt_get_dump_data(struct net_device *dev, struct ethtool_dump *dump, @@ -3336,7 +3358,16 @@ static int bnxt_get_dump_data(struct net_device *dev, struct ethtool_dump *dump, memset(buf, 0, dump->len); - return bnxt_get_coredump(bp, buf, &dump->len); + dump->flag = bp->dump_flag; + if (dump->flag == BNXT_DUMP_CRASH) { +#ifdef CONFIG_TEE_BNXT_FW + return tee_bnxt_copy_coredump(buf, 0, dump->len); +#endif + } else { + return bnxt_get_coredump(bp, buf, &dump->len); + } + + return 0; } void bnxt_ethtool_init(struct bnxt *bp) @@ -3446,6 +3477,7 @@ void bnxt_ethtool_free(struct bnxt *bp) .set_phys_id = bnxt_set_phys_id, .self_test = bnxt_self_test, .reset = bnxt_reset, + .set_dump = bnxt_set_dump, .get_dump_flag = bnxt_get_dump_flag, .get_dump_data = bnxt_get_dump_data, }; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h index b5b65b3..01de7e7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h @@ -59,6 +59,8 @@ struct hwrm_dbg_cmn_output { #define HWRM_DBG_CMN_FLAGS_MORE 1 }; +#define BNXT_CRASH_DUMP_LEN (8 << 20) + #define BNXT_LED_DFLT_ENA \ (PORT_LED_CFG_REQ_ENABLES_LED0_ID | \ PORT_LED_CFG_REQ_ENABLES_LED0_STATE | \ -- 1.9.1