From nobody Mon Jun 15 11:35:36 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gf7N8696xz6hBps for ; Mon, 15 Jun 2026 11:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gf7N83X69z3Jbb for ; Mon, 15 Jun 2026 11:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781523336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wpFXZdYt6lulZ2/pKhg2eBTFy0DR/OYm0BO7N7FpZbg=; b=hDWeJAVMeddRx2MVhDRPMeqkBmbk5vlzibx4RMvZUNj/rPkn8OcoKbaUdb7nFO90UJ6rdw MAkhYJcZ1mPYjudozg+J1MeZGcYx/i/g1aUndflb7a+FzpS6X3GWVh6MrV9J/hz9gFuVkG lIb33l4gXR/HQXvrqsbt8lqx43o5852ZbmOUz9877ULDoGU/4wCvj5yV9Z4TNXxW8PnhaD n7f8sbOw9wgd4YYzmLwniWoGH7PDqmkDuDzmi/4XYfH61L1iD6vmx7vzNL7b+PBZ62mSa6 QKWoGMFEMDAOLYxzRVbCa8jcu68g+8o7Ogki2uh9v4grldGHfXrxNuPJYLBz2Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781523336; a=rsa-sha256; cv=none; b=JoqZ47bexAF5vJ5A2TzP9Ha/p2cgv3m6gFrN6mP9VgL+sMgjueZg/z7Io0XyJPVp19AEpU yW6rzxd7XFVHJ4iGd5Tw/D9g+h4x/C9JJS9vt+0G7iV42ICG+b4U8ygOksZx0U8Z2sgyXg xcELfQnsHbkWQbAaz+H/wQm8dDsGtzGzO6B4HdR60ctXhBpnvMO/jvYuCUQUH4qz5rIAPG 2t00rMIs81yjm5o49xQ0XLLycV+7jToLxqLwxz0iOF+2UbXhzaluNB2S4ffqQR3HPY3RvJ +fOk3YBNHq1spaqa54uqazdqNnXdqxIFLAU+ouG9j+oYHXKwbx6wKE0ISHgt1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781523336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wpFXZdYt6lulZ2/pKhg2eBTFy0DR/OYm0BO7N7FpZbg=; b=nTH+noao6Upgf04KEvjNpSjEqDySYkKAJBYI4IpFJK4eYjYuB536sj055MYzneURGL3kEr LDpZ/yl3U12LfryXJn63xtiXD0oRcL/aUn6c4EM3AlR8iUdofCIvaP6bCSqTxHnLCHUATZ hGfBGsN+6GZmUwnSItWpJpNWJPShSnpW1CW25fWOmjsv6mnNpFSsIO4U0mAFEaesM9Ln6/ d5H9SwjQFmnhq2OOmYBV8JdV2mX8kYeP5szYLxMTMVH8T3VN7/QM6LOS2xxXFP+oW0oGoJ tIxunJs9iczsmTjlztTHjRNHpZHqoe/5qSvHeePmf5uR+MveFacyYFGqAFE21g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gf7N833qNzsx4 for ; Mon, 15 Jun 2026 11:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1ec9f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 15 Jun 2026 11:35:36 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Sreekanth Reddy From: Sumit Saxena Subject: git: 03839879a2dd - main - if_bnxt: Add Firmware crashdump collection support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ssaxena X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 03839879a2dd2505eab80b99211b0637ebdc9d32 Auto-Submitted: auto-generated Date: Mon, 15 Jun 2026 11:35:36 +0000 Message-Id: <6a2fe388.1ec9f.2de835f@gitrepo.freebsd.org> The branch main has been updated by ssaxena: URL: https://cgit.FreeBSD.org/src/commit/?id=03839879a2dd2505eab80b99211b0637ebdc9d32 commit 03839879a2dd2505eab80b99211b0637ebdc9d32 Author: Sreekanth Reddy AuthorDate: 2026-06-15 09:46:51 +0000 Commit: Sumit Saxena CommitDate: 2026-06-15 11:33:51 +0000 if_bnxt: Add Firmware crashdump collection support This patch adds support for DDR-based firmware coredump memory handling. It detects firmware coredump capability, allocates host DDR (DMA) memory for crash dumps, and programs the firmware with the allocated memory during attach. The allocated memory is released during driver detach. Also, This patch adds functions to retrieve crash dump data from host DDR memory. The implementation handles data copying from page tables and checks dump availability. Main function bnxt_get_coredump() copies stored crash dump data from DDR memory to the application buffer. MFC after: 2 weeks Reviewed by: gallatin, ssaxena Differential Revision: https://reviews.freebsd.org/D56684 --- sys/dev/bnxt/bnxt_en/bnxt.h | 20 ++++- sys/dev/bnxt/bnxt_en/bnxt_hwrm.c | 120 ++++++++++++++++++++++++++++++ sys/dev/bnxt/bnxt_en/bnxt_mgmt.c | 151 ++++++++++++++++++++++++++++++++++++++ sys/dev/bnxt/bnxt_en/bnxt_mgmt.h | 29 +++++++- sys/dev/bnxt/bnxt_en/if_bnxt.c | 48 ++++++++++-- sys/modules/bnxt/bnxt_en/Makefile | 1 + 6 files changed, 362 insertions(+), 7 deletions(-) diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h index 554e24563db6..dfbf1d8f03d3 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt.h +++ b/sys/dev/bnxt/bnxt_en/bnxt.h @@ -1129,6 +1129,18 @@ struct bnxt_softc { uint16_t hwrm_cmd_seq; uint32_t hwrm_cmd_timeo; /* milliseconds */ + + /* DDR Crash Dump Support */ + struct bnxt_ctx_pg_info *fw_crash_mem; + uint32_t fw_crash_len; + uint32_t fw_dbg_cap; + #define BNXT_FW_DBG_CAP_CRASHDUMP_SOC 0x00000001 + #define BNXT_FW_DBG_CAP_CRASHDUMP_HOST 0x00000002 + uint16_t dump_flag; + #define BNXT_DUMP_LIVE 0 + #define BNXT_DUMP_CRASH 1 + #define BNXT_DUMP_DRIVER 2 + #define BNXT_DUMP_LIVE_WITH_CTX_L1_CACHE 3 struct iflib_dma_info hwrm_cmd_resp; struct iflib_dma_info hwrm_short_cmd_req_addr; /* Interrupt info for HWRM */ @@ -1220,6 +1232,7 @@ struct bnxt_softc { struct sysctl_oid *dcb_oid; struct bnxt_ver_info *ver_info; + struct hwrm_ver_get_output ver_resp; struct bnxt_nvram_info *nvm_info; bool wol; bool is_dev_init; @@ -1439,5 +1452,10 @@ int bnxt_dcb_ieee_listapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app, size_t nitems, int *num_inputs); void bnxt_set_flags_by_devid(struct bnxt_softc *softc); int bnxt_hwrm_reserve_rings(struct bnxt_softc *softc); - +void bnxt_free_ctx_pg_tbls(struct bnxt_softc *softc, + struct bnxt_ctx_pg_info *ctx_pg); +int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc, + struct bnxt_ctx_pg_info *ctx_pg, + uint32_t mem_size, uint8_t depth, + struct bnxt_ctx_mem_type *ctxm); #endif /* _BNXT_H */ diff --git a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c index b89a44e4677b..5964511f8276 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c +++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c @@ -33,6 +33,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" #include "hsi_struct_def.h" +#include "bnxt_coredump.h" static int bnxt_hwrm_err_map(uint16_t err); static inline int _is_valid_ether_addr(uint8_t *); @@ -889,6 +890,8 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc) if (rc) goto fail; + memcpy(&softc->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); + snprintf(softc->ver_info->hwrm_if_ver, BNXT_VERSTR_SIZE, "%d.%d.%d", resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, resp->hwrm_intf_upd_8b); softc->ver_info->hwrm_if_major = resp->hwrm_intf_maj_8b; @@ -3327,3 +3330,120 @@ void bnxt_hwrm_ring_info_get(struct bnxt_softc *softc, uint8_t ring_type, return; } + +/* Query debug capabilities */ +void +bnxt_hwrm_dbg_qcaps(struct bnxt_softc *softc) +{ + hwrm_dbg_qcaps_input_t req = {0}; + hwrm_dbg_qcaps_output_t *resp; + uint32_t flags; + int rc; + + softc->fw_dbg_cap = 0; + if (!(softc->fw_cap & BNXT_FW_CAP_DBG_QCAPS)) + return; + + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_DBG_QCAPS); + req.fid = htole16(0xffff); + resp = (hwrm_dbg_qcaps_output_t *)(void *) + softc->hwrm_cmd_resp.idi_vaddr; + rc = hwrm_send_message(softc, &req, sizeof(req)); + if (rc) + return; + + flags = le32toh(resp->flags); + if (flags & HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_SOC_DDR) + softc->fw_dbg_cap |= BNXT_FW_DBG_CAP_CRASHDUMP_SOC; + if (flags & HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_HOST_DDR) + softc->fw_dbg_cap |= BNXT_FW_DBG_CAP_CRASHDUMP_HOST; +} + +/* Configure firmware with DDR crash dump memory */ +int +bnxt_hwrm_crash_dump_mem_cfg(struct bnxt_softc *softc) +{ + hwrm_dbg_crashdump_medium_cfg_input_t req = {0}; + uint16_t page_attr = 0; + int rc; + + if (!(softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_HOST)) + return (0); + + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_DBG_CRASHDUMP_MEDIUM_CFG); + + if (BNXT_PAGE_SIZE == 0x2000) + page_attr = HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_8K; + else if (BNXT_PAGE_SIZE == 0x10000) + page_attr = HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_64K; + else + page_attr = HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_4K; + + req.pg_size_lvl = htole16(page_attr | + softc->fw_crash_mem->ring_mem.depth); + + if (softc->fw_crash_mem->ring_mem.depth > 1) + req.pbl = htole64( + softc->fw_crash_mem->ring_mem.pg_tbl.idi_paddr); + else + req.pbl = htole64( + softc->fw_crash_mem->ring_mem.pg_arr[0].idi_paddr); + + req.size = htole32(softc->fw_crash_len); + req.output_dest_flags = htole16( + HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_TYPE_DDR); + + rc = hwrm_send_message(softc, &req, sizeof(req)); + return (rc); +} + +/* Get dump length from firmware */ +int +bnxt_hwrm_get_dump_len(struct bnxt_softc *softc, uint16_t dump_type, + uint32_t *dump_len) +{ + hwrm_dbg_qcfg_output_t *resp; + hwrm_dbg_qcfg_input_t req = {0}; + int rc; + + if (!(softc->fw_cap & BNXT_FW_CAP_DBG_QCAPS) || + dump_type == BNXT_DUMP_DRIVER) + return (-EOPNOTSUPP); + + if (dump_type == BNXT_DUMP_CRASH && + !(softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_SOC || + (softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_HOST))) + return (-EOPNOTSUPP); + + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_DBG_QCFG); + + req.fid = htole16(0xffff); + if (dump_type == BNXT_DUMP_CRASH) { + if (softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_SOC) + req.flags = htole16( + HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR); + else + req.flags = htole16( + HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_HOST_DDR); + } + + resp = (hwrm_dbg_qcfg_output_t *)(void *)softc->hwrm_cmd_resp.idi_vaddr; + rc = hwrm_send_message(softc, &req, sizeof(req)); + if (rc) + goto get_dump_len_exit; + + if (dump_type == BNXT_DUMP_CRASH) { + if (softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_SOC) + *dump_len = BNXT_CRASH_DUMP_LEN; + else + *dump_len = le32toh(resp->crashdump_size); + } else { + *dump_len = le32_to_cpu(resp->coredump_size); + } + if (*dump_len <= 0) + rc = -EINVAL; + +get_dump_len_exit: + return (rc); +} + diff --git a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c index fd6d7b904dca..0a12bea17ead 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c +++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c @@ -29,6 +29,7 @@ #include "bnxt_mgmt.h" #include "bnxt.h" #include "bnxt_hwrm.h" +#include "bnxt_coredump.h" #include "bnxt_log.h" #include #include @@ -266,6 +267,152 @@ bnxt_get_ctx_coredump(struct bnxt_softc *softc, void *buf) } } +/* DDR Crash Dump IOCTL handler */ +static int +bnxt_mgmt_crash_dump(struct cdev *dev, u_long cmd, caddr_t data, + int flag, struct thread *td) +{ + struct bnxt_softc *softc = NULL; + struct bnxt_mgmt_crash_dump mgmt_crash_dump = {0}; + void *user_ptr; + int ret = 0; + void *dump_buf = NULL; + uint32_t dump_len; + + memcpy(&user_ptr, data, sizeof(user_ptr)); + if (copyin(user_ptr, &mgmt_crash_dump, sizeof(mgmt_crash_dump))) { + printf("%s: %s:%d Failed to copy data from user\n", + DRIVER_NAME, __func__, __LINE__); + return (-EFAULT); + } + softc = bnxt_find_dev(mgmt_crash_dump.hdr.domain, + mgmt_crash_dump.hdr.bus, + mgmt_crash_dump.hdr.devfn, NULL); + if (!softc) { + printf("%s: %s:%d unable to find softc reference\n", + DRIVER_NAME, __func__, __LINE__); + return (-ENODEV); + } + + switch (mgmt_crash_dump.op) { + case BNXT_MGMT_SET_DUMP_FLAG: + if (mgmt_crash_dump.req.set_flag.dump_flag > + BNXT_DUMP_LIVE_WITH_CTX_L1_CACHE) { + device_printf(softc->dev, + "Supports only Live(0), Crash(1), Driver(2), " + "Live with cached context(3) dumps.\n"); + ret = -EINVAL; + break; + } + + if (mgmt_crash_dump.req.set_flag.dump_flag == BNXT_DUMP_CRASH) { + if (softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_SOC) { + device_printf(softc->dev, + "Cannot collect crash dump as TEE is not supported.\n"); + ret = -ENOTSUP; + break; + } else if (!(softc->fw_dbg_cap & + BNXT_FW_DBG_CAP_CRASHDUMP_HOST)) { + device_printf(softc->dev, + "FW does not support crash dump collection.\n"); + ret = -ENOTSUP; + break; + } + } + + softc->dump_flag = mgmt_crash_dump.req.set_flag.dump_flag; + break; + + case BNXT_MGMT_GET_DUMP_FLAG: + if (softc->hwrm_spec_code < 0x10801) { + ret = -ENOTSUP; + break; + } + + /* Build FW version - same as Linux bnxt_get_dump_flag() */ + mgmt_crash_dump.req.get_flag.version = + (softc->ver_resp.hwrm_fw_maj_8b << 24) | + (softc->ver_resp.hwrm_fw_min_8b << 16) | + (softc->ver_resp.hwrm_fw_bld_8b << 8) | + (softc->ver_resp.hwrm_fw_rsvd_8b); + + mgmt_crash_dump.req.get_flag.dump_flag = softc->dump_flag; + mgmt_crash_dump.req.get_flag.dump_len = + bnxt_get_coredump_length(softc, softc->dump_flag); + break; + + case BNXT_MGMT_GET_DUMP_DATA: + if (softc->hwrm_spec_code < 0x10801) { + ret = -ENOTSUP; + break; + } + + dump_len = bnxt_get_coredump_length(softc, + mgmt_crash_dump.req.get_data.dump_flag); + if (dump_len == 0) { + device_printf(softc->dev, "No dump data available\n"); + ret = -ENOENT; + break; + } + + if (mgmt_crash_dump.req.get_data.buffer_size < dump_len) { + device_printf(softc->dev, + "Buffer too small: need %u bytes, got %zu bytes\n", + dump_len, mgmt_crash_dump.req.get_data.buffer_size); + mgmt_crash_dump.req.get_data.dump_len = dump_len; + ret = -ENOSPC; + break; + } + + dump_buf = malloc(dump_len, M_BNXT, M_WAITOK); + if (!dump_buf) { + ret = -ENOMEM; + break; + } + + ret = bnxt_get_coredump(softc, + mgmt_crash_dump.req.get_data.dump_flag, + dump_buf, &dump_len); + if (ret) { + device_printf(softc->dev, + "Failed to get coredump: %d\n", ret); + free(dump_buf, M_BNXT); + break; + } + + if (copyout(dump_buf, + mgmt_crash_dump.req.get_data.dump_buffer, dump_len)) { + device_printf(softc->dev, + "%s:%d Failed to copy dump data to user\n", + __func__, __LINE__); + ret = -EFAULT; + free(dump_buf, M_BNXT); + break; + } + + mgmt_crash_dump.req.get_data.dump_len = dump_len; + mgmt_crash_dump.req.get_data.dump_flag = softc->dump_flag; + free(dump_buf, M_BNXT); + break; + + default: + device_printf(softc->dev, "%s:%d Invalid op 0x%x\n", + __func__, __LINE__, mgmt_crash_dump.op); + ret = -EFAULT; + break; + } + + if (!ret && copyout(&mgmt_crash_dump, user_ptr, + sizeof(mgmt_crash_dump))) { + device_printf(softc->dev, + "%s:%d Failed to copy response to user\n", + __func__, __LINE__); + ret = -EFAULT; + } + + return (ret); +} + /* * This function is called by the kld[un]load(2) system calls to * determine what actions to take when a module is loaded or unloaded. @@ -693,6 +840,10 @@ bnxt_mgmt_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, case IOW_BNXT_MGMT_OPCODE_DRV_DUMP: ret = bnxt_mgmt_drv_dump(dev, cmd, data, flag, td); break; + case IO_BNXT_MGMT_OPCODE_CRASH_DUMP: + case IOW_BNXT_MGMT_OPCODE_CRASH_DUMP: + ret = bnxt_mgmt_crash_dump(dev, cmd, data, flag, td); + break; default: printf("%s: Unknown command 0x%lx\n", DRIVER_NAME, cmd); ret = -EINVAL; diff --git a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h index cdd6964158ee..272fb0e298cb 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h +++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h @@ -44,11 +44,13 @@ #define IOW_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM _IOW(0, 1, 0) #define IOW_BNXT_MGMT_OPCODE_DCB_OPS _IOW(0, 2, 0) #define IOW_BNXT_MGMT_OPCODE_DRV_DUMP _IOW(0, 3, 0) +#define IOW_BNXT_MGMT_OPCODE_CRASH_DUMP _IOW(0, 4, 0) #define IO_BNXT_MGMT_OPCODE_GET_DEV_INFO _IO(0, 0) #define IO_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM _IO(0, 1) #define IO_BNXT_MGMT_OPCODE_DCB_OPS _IO(0, 2) #define IO_BNXT_MGMT_OPCODE_DRV_DUMP _IO(0, 3) +#define IO_BNXT_MGMT_OPCODE_CRASH_DUMP _IO(0, 4) #define BNXT_MGMT_MAX_HWRM_REQ_LENGTH HWRM_MAX_REQ_LEN #define BNXT_MGMT_MAX_HWRM_RESP_LENGTH (512) @@ -81,7 +83,7 @@ struct bnxt_pci_info { } __packed; struct bnxt_dev_info { - struct bnxt_nic_info nic_info; + struct bnxt_nic_info nic_info; struct bnxt_pci_info pci_info; } __packed; @@ -165,6 +167,31 @@ struct bnxt_mgmt_drv_dump { uint32_t buf_size; } __attribute__ ((__packed__)); +struct bnxt_mgmt_crash_dump { + struct bnxt_mgmt_req_hdr hdr; +#define BNXT_MGMT_SET_DUMP_FLAG 0x1 +#define BNXT_MGMT_GET_DUMP_FLAG 0x2 +#define BNXT_MGMT_GET_DUMP_DATA 0x3 +#define BNXT_MGMT_CRASH_DUMP_MAX BNXT_MGMT_GET_DUMP_DATA + uint32_t op; + union { + struct { + uint32_t dump_flag; + } set_flag; + struct { + uint32_t dump_flag; + uint32_t dump_len; + uint32_t version; + } get_flag; + struct { + uint32_t dump_flag; + uint32_t dump_len; + void *dump_buffer; + size_t buffer_size; + } get_data; + } req; +} __attribute__ ((__packed__)); + struct bnxt_driver_segment_record { uint32_t max_entries; uint32_t entry_size; diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c index 83f339bb045f..c10a66156563 100644 --- a/sys/dev/bnxt/bnxt_en/if_bnxt.c +++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c @@ -73,6 +73,7 @@ #include "bnxt_auxbus_compat.h" #include "bnxt_log.h" #include "bnxt_log_data.h" +#include "bnxt_coredump.h" /* * PCI Device ID Table @@ -269,6 +270,7 @@ static void bnxt_queue_fw_reset_work(struct bnxt_softc *bp, unsigned long delay) void bnxt_queue_sp_work(struct bnxt_softc *bp); void bnxt_fw_reset(struct bnxt_softc *bp); +static int bnxt_crash_dump_init(struct bnxt_softc *softc); /* * Device Interface Declaration */ @@ -1101,9 +1103,10 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt_softc *softc, return bnxt_alloc_ring(softc, rmem); } -static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc, - struct bnxt_ctx_pg_info *ctx_pg, u32 mem_size, - u8 depth, struct bnxt_ctx_mem_type *ctxm) +int +bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc, + struct bnxt_ctx_pg_info *ctx_pg, uint32_t mem_size, uint8_t depth, + struct bnxt_ctx_mem_type *ctxm) { struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; int rc; @@ -1161,8 +1164,8 @@ static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc, return rc; } -static void bnxt_free_ctx_pg_tbls(struct bnxt_softc *softc, - struct bnxt_ctx_pg_info *ctx_pg) +void bnxt_free_ctx_pg_tbls(struct bnxt_softc *softc, + struct bnxt_ctx_pg_info *ctx_pg) { struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; @@ -2241,6 +2244,8 @@ static int bnxt_open(struct bnxt_softc *bp) if (rc) return rc; + bnxt_hwrm_dbg_qcaps(bp); + /* Register the driver with the FW */ rc = bnxt_drv_rgtr(bp); if (rc) @@ -2388,6 +2393,7 @@ static void bnxt_fw_reset_task(struct work_struct *work) bnxt_ulp_start(bp, 0); clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); set_bit(BNXT_STATE_OPEN, &bp->state); + bnxt_crash_dump_init(bp); #ifdef PCI_IOV bnxt_reenable_sriov(bp); #endif @@ -2514,6 +2520,29 @@ bnxt_log_live_data(void *d) bnxt_log_ring_states(bp); } +/* DDR Crash Dump Setup */ +static int +bnxt_crash_dump_init(struct bnxt_softc *softc) +{ + int rc; + + rc = bnxt_alloc_crash_dump_mem(softc); + if (rc) { + device_printf(softc->dev, + "crash dump mem alloc failure rc: %d\n", rc); + return (rc); + } + + rc = bnxt_hwrm_crash_dump_mem_cfg(softc); + if (rc) { + bnxt_free_crash_dump_mem(softc); + device_printf(softc->dev, + "hwrm crash dump mem failure rc: %d\n", rc); + } + + return (rc); +} + /* Device setup and teardown */ static int bnxt_attach_pre(if_ctx_t ctx) @@ -2706,6 +2735,8 @@ bnxt_attach_pre(if_ctx_t ctx) } } + bnxt_hwrm_dbg_qcaps(softc); + /* * Register the driver with the FW * Register the async events with the FW @@ -2893,6 +2924,7 @@ bnxt_attach_pre(if_ctx_t ctx) return (rc); + failed: bnxt_free_sysctl_ctx(softc); init_sysctl_failed: @@ -2952,6 +2984,11 @@ bnxt_attach_post(if_ctx_t ctx) if (BNXT_PF(softc) && BNXT_CHIP_P5_PLUS(softc)) bnxt_sriov_attach(softc); + rc = bnxt_crash_dump_init(softc); + if (rc) + device_printf(softc->dev, + "crash dump init failure rc: %d\n", rc); + failed: return rc; } @@ -2973,6 +3010,7 @@ bnxt_detach(if_ctx_t ctx) bnxt_wol_config(ctx); bnxt_do_disable_intr(&softc->def_cp_ring); bnxt_free_sysctl_ctx(softc); + bnxt_free_crash_dump_mem(softc); bnxt_hwrm_func_reset(softc); bnxt_free_ctx_mem(softc); bnxt_clear_ids(softc); diff --git a/sys/modules/bnxt/bnxt_en/Makefile b/sys/modules/bnxt/bnxt_en/Makefile index 7cb450baac4e..e3cc3e79377c 100644 --- a/sys/modules/bnxt/bnxt_en/Makefile +++ b/sys/modules/bnxt/bnxt_en/Makefile @@ -13,6 +13,7 @@ SRCS += bnxt_sriov.c bnxt_sriov.h SRCS += bnxt_ulp.c bnxt_ulp.h SRCS += bnxt_log.c bnxt_log.h SRCS += bnxt_log_data.c bnxt_log_data.h +SRCS += bnxt_coredump.c bnxt_coredump.h SRCS += ${LINUXKPI_GENSRCS} CFLAGS+= -DIFLIB