Commit 0b0eacf3 authored by Vasundhara Volam's avatar Vasundhara Volam Committed by David S. Miller
Browse files

bnxt_en: Add support to collect crash dump via ethtool



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

v3: Modify set_dump to support even when CONFIG_TEE_BNXT_FW=n.
Also change log message to netdev_info().

Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: default avatarSheetal Tigadoli <sheetal.tigadoli@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e07ab202
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;

+35 −2
Original line number Diff line number Diff line
@@ -3311,6 +3311,24 @@ err:
	return rc;
}

static int bnxt_set_dump(struct net_device *dev, struct ethtool_dump *dump)
{
	struct bnxt *bp = netdev_priv(dev);

	if (dump->flag > BNXT_DUMP_CRASH) {
		netdev_info(dev, "Supports only Live(0) and Crash(1) dumps.\n");
		return -EINVAL;
	}

	if (!IS_ENABLED(CONFIG_TEE_BNXT_FW) && dump->flag == BNXT_DUMP_CRASH) {
		netdev_info(dev, "Cannot collect crash dump as TEE_BNXT_FW config option is not enabled.\n");
		return -EOPNOTSUPP;
	}

	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 +3341,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,9 +3359,18 @@ static int bnxt_get_dump_data(struct net_device *dev, struct ethtool_dump *dump,

	memset(buf, 0, 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)
{
	struct hwrm_selftest_qlist_output *resp = bp->hwrm_cmd_resp_addr;
@@ -3446,6 +3478,7 @@ const struct ethtool_ops bnxt_ethtool_ops = {
	.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,
};
+2 −0
Original line number Diff line number Diff line
@@ -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 |		\