git: 9931dc5bf383 - main - if_bnxt: add few source files to version control
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 Jun 2026 14:40:56 UTC
The branch main has been updated by ssaxena:
URL: https://cgit.FreeBSD.org/src/commit/?id=9931dc5bf3831146c08a381c42ecbfcedb8ac7f1
commit 9931dc5bf3831146c08a381c42ecbfcedb8ac7f1
Author: Sumit Saxena <ssaxena@FreeBSD.org>
AuthorDate: 2026-06-15 14:30:26 +0000
Commit: Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2026-06-15 14:40:39 +0000
if_bnxt: add few source files to version control
Commits- f85e66e655c9 ("if_bnxt/bnxt_re: add support for driver snapdump")
and 03839879a2dd ("if_bnxt: Add Firmware crashdump collection support")
missed to add few files under version control, those files are
added now:
sys/dev/bnxt/bnxt_en/bnxt_log.c
sys/dev/bnxt/bnxt_en/bnxt_log.h
sys/dev/bnxt/bnxt_en/bnxt_log_data.c
sys/dev/bnxt/bnxt_en/bnxt_log_data.h
sys/dev/bnxt/bnxt_en/bnxt_coredump.c
sys/dev/bnxt/bnxt_en/bnxt_coredump.h
bnxt_coredump.c entry is added in sys/conf/files as well.
Fixes: f85e66e655c9 ("if_bnxt/bnxt_re: add support for driver snapdump")
Fixes: 03839879a2dd ("if_bnxt: Add Firmware crashdump collection support")
---
sys/conf/files | 1 +
sys/dev/bnxt/bnxt_en/bnxt_coredump.c | 186 ++++++++++++++++++++
sys/dev/bnxt/bnxt_en/bnxt_coredump.h | 50 ++++++
sys/dev/bnxt/bnxt_en/bnxt_log.c | 318 +++++++++++++++++++++++++++++++++++
sys/dev/bnxt/bnxt_en/bnxt_log.h | 123 ++++++++++++++
sys/dev/bnxt/bnxt_en/bnxt_log_data.c | 78 +++++++++
sys/dev/bnxt/bnxt_en/bnxt_log_data.h | 35 ++++
7 files changed, 791 insertions(+)
diff --git a/sys/conf/files b/sys/conf/files
index 67f0dcedd346..1332f4bd8cc6 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1328,6 +1328,7 @@ dev/bnxt/bnxt_en/bnxt_txrx.c optional bnxt iflib pci compile-with "${BNXT_C}"
dev/bnxt/bnxt_en/bnxt_ulp.c optional bnxt iflib pci compile-with "${BNXT_C}"
dev/bnxt/bnxt_en/bnxt_log.c optional bnxt iflib pci compile-with "${BNXT_C}"
dev/bnxt/bnxt_en/bnxt_log_data.c optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_coredump.c optional bnxt iflib pci compile-with "${BNXT_C}"
dev/bnxt/bnxt_en/if_bnxt.c optional bnxt iflib pci compile-with "${BNXT_C}"
dev/bwi/bwimac.c optional bwi
dev/bwi/bwiphy.c optional bwi
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_coredump.c b/sys/dev/bnxt/bnxt_en/bnxt_coredump.c
new file mode 100644
index 000000000000..6aafa9182883
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_coredump.c
@@ -0,0 +1,186 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom Inc. All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include "bnxt.h"
+#include "bnxt_coredump.h"
+#include "hsi_struct_def.h"
+
+
+/* Free crash dump memory */
+void
+bnxt_free_crash_dump_mem(struct bnxt_softc *softc)
+{
+ if (softc->fw_crash_mem) {
+ bnxt_free_ctx_pg_tbls(softc, softc->fw_crash_mem);
+ free(softc->fw_crash_mem, M_DEVBUF);
+ softc->fw_crash_len = 0;
+ softc->fw_crash_mem = NULL;
+ }
+}
+
+/* Allocate crash dump memory */
+int
+bnxt_alloc_crash_dump_mem(struct bnxt_softc *softc)
+{
+ uint32_t mem_size = 0;
+ int rc;
+
+ if (!(softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_HOST))
+ return (0);
+
+ rc = bnxt_hwrm_get_dump_len(softc, BNXT_DUMP_CRASH, &mem_size);
+ if (rc)
+ return (rc);
+
+ mem_size = roundup(mem_size, 4);
+
+ if (softc->fw_crash_mem && mem_size == softc->fw_crash_len)
+ return (0);
+
+ bnxt_free_crash_dump_mem(softc);
+
+ softc->fw_crash_mem = malloc(sizeof(*softc->fw_crash_mem),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (!softc->fw_crash_mem)
+ return (-ENOMEM);
+
+ rc = bnxt_alloc_ctx_pg_tbls(softc, softc->fw_crash_mem,
+ mem_size, 1, NULL);
+ if (rc) {
+ bnxt_free_crash_dump_mem(softc);
+ return (rc);
+ }
+
+ softc->fw_crash_len = mem_size;
+ return (0);
+}
+
+/* Copy crash data from ring memory */
+static uint32_t
+bnxt_copy_crash_data(struct bnxt_ring_mem_info *rmem, void *buf,
+ uint32_t dump_len)
+{
+ uint32_t data_copied = 0;
+ uint32_t data_len;
+ int i;
+
+ for (i = 0; i < rmem->nr_pages; i++) {
+ if (!rmem->pg_arr[i].idi_vaddr)
+ continue;
+ data_len = rmem->page_size;
+ if (data_copied + data_len > dump_len)
+ data_len = dump_len - data_copied;
+ memcpy((uint8_t *)buf + data_copied,
+ rmem->pg_arr[i].idi_vaddr, data_len);
+ data_copied += data_len;
+ if (data_copied >= dump_len)
+ break;
+ }
+ return (data_copied);
+}
+
+/* Copy crash dump from DDR memory */
+static int
+bnxt_copy_crash_dump(struct bnxt_softc *softc, void *buf, uint32_t dump_len)
+{
+ struct bnxt_ring_mem_info *rmem;
+ uint32_t offset = 0;
+
+ if (!softc->fw_crash_mem)
+ return (-ENOENT);
+
+ rmem = &softc->fw_crash_mem->ring_mem;
+
+ if (rmem->depth > 1) {
+ int i;
+
+ for (i = 0; i < rmem->nr_pages; i++) {
+ struct bnxt_ctx_pg_info *pg_tbl;
+
+ pg_tbl = softc->fw_crash_mem->ctx_pg_tbl[i];
+ if (!pg_tbl)
+ continue;
+ offset += bnxt_copy_crash_data(&pg_tbl->ring_mem,
+ (uint8_t *)buf + offset,
+ dump_len - offset);
+ if (offset >= dump_len)
+ break;
+ }
+ } else {
+ bnxt_copy_crash_data(rmem, buf, dump_len);
+ }
+
+ return (0);
+}
+
+/* Check if crash dump is available */
+static bool
+bnxt_crash_dump_avail(struct bnxt_softc *softc)
+{
+ uint32_t sig = 0;
+
+ /* First 4 bytes(signature) of crash dump is always non-zero */
+ bnxt_copy_crash_dump(softc, &sig, sizeof(uint32_t));
+ return (!!sig);
+}
+
+/* Get coredump */
+int
+bnxt_get_coredump(struct bnxt_softc *softc, uint16_t dump_type, void *buf,
+ uint32_t *dump_len)
+{
+ if (dump_type == BNXT_DUMP_CRASH &&
+ softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_HOST) {
+ return (bnxt_copy_crash_dump(softc, buf, *dump_len));
+ } else {
+ /* Other dump types not implemented yet */
+ return (-EOPNOTSUPP);
+ }
+}
+
+/* Get coredump length */
+uint32_t
+bnxt_get_coredump_length(struct bnxt_softc *softc, uint16_t dump_type)
+{
+ uint32_t len = 0;
+
+ if (dump_type == BNXT_DUMP_CRASH &&
+ softc->fw_dbg_cap & BNXT_FW_DBG_CAP_CRASHDUMP_HOST &&
+ softc->fw_crash_mem) {
+ if (!bnxt_crash_dump_avail(softc))
+ return (0);
+
+ return (softc->fw_crash_len);
+ }
+
+ if (bnxt_hwrm_get_dump_len(softc, dump_type, &len))
+ return (0);
+
+ return (len);
+}
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_coredump.h b/sys/dev/bnxt/bnxt_en/bnxt_coredump.h
new file mode 100644
index 000000000000..4af42b707987
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_coredump.h
@@ -0,0 +1,50 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom Inc. All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BNXT_COREDUMP_H
+#define _BNXT_COREDUMP_H
+
+#define BNXT_CRASH_DUMP_LEN 0x400000 /* 4MB default for SOC DDR */
+
+/* Capability detection */
+void bnxt_hwrm_dbg_qcaps(struct bnxt_softc *softc);
+
+/* Memory management */
+int bnxt_alloc_crash_dump_mem(struct bnxt_softc *softc);
+void bnxt_free_crash_dump_mem(struct bnxt_softc *softc);
+int bnxt_hwrm_crash_dump_mem_cfg(struct bnxt_softc *softc);
+int bnxt_hwrm_get_dump_len(struct bnxt_softc *softc, uint16_t dump_type,
+ uint32_t *dump_len);
+
+/* Coredump retrieval */
+uint32_t bnxt_get_coredump_length(struct bnxt_softc *softc, uint16_t dump_type);
+int bnxt_get_coredump(struct bnxt_softc *softc, uint16_t dump_type, void *buf,
+ uint32_t *dump_len);
+
+
+#endif /* _BNXT_COREDUMP_H */
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_log.c b/sys/dev/bnxt/bnxt_en/bnxt_log.c
new file mode 100644
index 000000000000..e891dab80491
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_log.c
@@ -0,0 +1,318 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/endian.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/systm.h>
+
+#include "bnxt.h"
+#include "bnxt_log.h"
+
+MALLOC_DEFINE(M_BNXT_LOG, "bnxt_log_buffer", "buffer for bnxt logging module");
+
+void
+bnxt_fill_coredump_seg_hdr(struct bnxt_softc *bp,
+ struct bnxt_coredump_segment_hdr *seg_hdr,
+ struct coredump_segment_record *seg_rec,
+ uint32_t seg_len, int status, uint32_t duration,
+ uint32_t instance, uint32_t comp_id, uint32_t seg_id)
+{
+ memset(seg_hdr, 0, sizeof(*seg_hdr));
+ memcpy(seg_hdr->signature, "sEgM", 4);
+ if (seg_rec) {
+ seg_hdr->component_id =
+ htole32((uint32_t)seg_rec->component_id);
+ seg_hdr->segment_id = htole32((uint32_t)seg_rec->segment_id);
+ seg_hdr->low_version = seg_rec->version_low;
+ seg_hdr->high_version = seg_rec->version_hi;
+ seg_hdr->flags = seg_rec->compress_flags;
+ } else {
+ seg_hdr->component_id = htole32(comp_id);
+ seg_hdr->segment_id = htole32(seg_id);
+ }
+ seg_hdr->function_id = htole16(bp->func.fw_fid);
+ seg_hdr->length = htole32(seg_len);
+ seg_hdr->status = htole32((uint32_t)status);
+ seg_hdr->duration = htole32(duration);
+ seg_hdr->data_offset = htole32(sizeof(*seg_hdr));
+ seg_hdr->instance = htole32(instance);
+}
+
+int
+bnxt_register_logger(struct bnxt_softc *bp, uint16_t logger_id,
+ uint32_t num_buffs, void (*log_live)(void *),
+ uint32_t live_max_size)
+{
+ struct bnxt_logger *logger;
+ void *data;
+
+ if (!log_live || !live_max_size)
+ return (EINVAL);
+
+ if (num_buffs == 0 || (num_buffs & (num_buffs - 1)) != 0)
+ return (EINVAL);
+
+ logger = malloc(sizeof(*logger), M_BNXT_LOG, M_WAITOK | M_ZERO);
+
+ logger->logger_id = logger_id;
+ logger->buffer_size = num_buffs * BNXT_LOG_MSG_SIZE;
+ logger->log_live_op = log_live;
+ logger->max_live_buff_size = live_max_size;
+
+ data = malloc(logger->buffer_size, M_BNXT_LOG, M_WAITOK);
+ logger->msgs = data;
+
+ mtx_lock(&bp->log_lock);
+ TAILQ_INSERT_TAIL(&bp->loggers_list, logger, list);
+ mtx_unlock(&bp->log_lock);
+ return (0);
+}
+
+void
+bnxt_unregister_logger(struct bnxt_softc *bp, int logger_id)
+{
+ struct bnxt_logger *l = NULL, *tmp;
+
+ mtx_lock(&bp->log_lock);
+ TAILQ_FOREACH_SAFE(l, &bp->loggers_list, list, tmp) {
+ if (l->logger_id == logger_id) {
+ TAILQ_REMOVE(&bp->loggers_list, l, list);
+ break;
+ }
+ }
+ mtx_unlock(&bp->log_lock);
+
+ if (!l) {
+ device_printf(bp->dev, "logger id %d not registered\n",
+ logger_id);
+ return;
+ }
+
+ free(l->msgs, M_BNXT_LOG);
+ free(l, M_BNXT_LOG);
+}
+
+static int
+bnxt_log_info(char *buf, size_t max_len, const char *format, va_list args)
+{
+ static char textbuf[BNXT_LOG_MSG_SIZE];
+ char *text = textbuf;
+ size_t text_len;
+ char *next;
+
+ text_len = vsnprintf(text, sizeof(textbuf), format, args);
+ if (text_len >= sizeof(textbuf))
+ text_len = sizeof(textbuf) - 1;
+
+ next = memchr(text, '\n', text_len);
+ if (next)
+ text_len = next - text;
+ else if (text[text_len] == '\0')
+ text[text_len] = '\n';
+
+ if (text_len > max_len) {
+ /* Truncate */
+ text_len = max_len;
+ text[text_len] = '\n';
+ }
+
+ memcpy(buf, text, text_len + 1);
+
+ return (text_len + 1);
+}
+
+void
+bnxt_log_add_msg(struct bnxt_softc *bp, uint16_t logger_id,
+ const char *format, ...)
+{
+ struct bnxt_logger *logger = NULL, *tmp;
+ uint16_t start, tail;
+ va_list args;
+ void *buf;
+ uint32_t mask;
+
+ mtx_lock(&bp->log_lock);
+ TAILQ_FOREACH_SAFE(logger, &bp->loggers_list, list, tmp) {
+ if (logger->logger_id == logger_id)
+ break;
+ }
+
+ if (!logger) {
+ mtx_unlock(&bp->log_lock);
+ return;
+ }
+
+ mask = BNXT_LOG_NUM_BUFFERS(logger->buffer_size) - 1;
+ tail = logger->tail;
+ start = logger->head;
+
+ if (logger->valid && start == tail)
+ logger->head = ++start & mask;
+
+ buf = (uint8_t *)logger->msgs + BNXT_LOG_MSG_SIZE * logger->tail;
+ logger->tail = ++tail & mask;
+
+ if (!logger->valid)
+ logger->valid = true;
+
+ va_start(args, format);
+ bnxt_log_info(buf, BNXT_LOG_MSG_SIZE, format, args);
+ va_end(args);
+ mtx_unlock(&bp->log_lock);
+}
+
+void
+bnxt_log_live(struct bnxt_softc *bp, uint16_t logger_id,
+ const char *format, ...)
+{
+ struct bnxt_logger *logger = NULL, *tmp;
+ va_list args;
+ int len;
+
+ TAILQ_FOREACH_SAFE(logger, &bp->loggers_list, list, tmp) {
+ if (logger->logger_id == logger_id)
+ break;
+ }
+
+ if (!logger || !logger->live_msgs)
+ return;
+
+ va_start(args, format);
+ len = bnxt_log_info(
+ (uint8_t *)logger->live_msgs + logger->live_msgs_len,
+ logger->max_live_buff_size - logger->live_msgs_len,
+ format, args);
+ va_end(args);
+
+ logger->live_msgs_len += len;
+}
+
+static size_t
+bnxt_get_data_len(char *buf)
+{
+ size_t count = 0;
+
+ while (*buf++ != '\n')
+ count++;
+ return (count + 1);
+}
+
+static size_t
+bnxt_collect_logs_buffer(struct bnxt_logger *logger, char *dest)
+{
+ uint32_t mask = BNXT_LOG_NUM_BUFFERS(logger->buffer_size) - 1;
+ uint16_t head = logger->head;
+ uint16_t tail = logger->tail;
+ size_t total_len = 0;
+ int count;
+
+ if (!logger->valid)
+ return (0);
+
+ count = (tail > head) ? (tail - head) : (tail - head + mask + 1);
+ while (count--) {
+ void *src = (uint8_t *)logger->msgs +
+ BNXT_LOG_MSG_SIZE * (head & mask);
+ size_t len;
+
+ len = bnxt_get_data_len(src);
+ memcpy(dest + total_len, src, len);
+ total_len += len;
+ head++;
+ }
+
+ return (total_len);
+}
+
+size_t
+bnxt_get_loggers_coredump_size(struct bnxt_softc *bp)
+{
+ struct bnxt_logger *logger, *tmp;
+ size_t len = 0;
+
+ mtx_lock(&bp->log_lock);
+ TAILQ_FOREACH_SAFE(logger, &bp->loggers_list, list, tmp) {
+ len += sizeof(struct bnxt_coredump_segment_hdr) +
+ logger->max_live_buff_size + logger->buffer_size;
+ }
+ mtx_unlock(&bp->log_lock);
+ return (len);
+}
+
+int
+bnxt_start_logging_driver_coredump(struct bnxt_softc *bp, char *dest_buf)
+{
+ struct bnxt_logger *logger, *tmp;
+ size_t offset = 0;
+ uint32_t seg_id = 0;
+
+ if (!dest_buf)
+ return (0);
+
+ mtx_lock(&bp->log_lock);
+ TAILQ_FOREACH_SAFE(logger, &bp->loggers_list, list, tmp) {
+ struct bnxt_coredump_segment_hdr seg_hdr;
+ void *seg_hdr_dest = dest_buf + offset;
+ size_t len;
+
+ offset += sizeof(seg_hdr);
+ /* First collect logs from buffer */
+ len = bnxt_collect_logs_buffer(logger, dest_buf + offset);
+ offset += len;
+ /* Let logger to collect live messages */
+ logger->live_msgs = dest_buf + offset;
+ logger->live_msgs_len = 0;
+ logger->log_live_op(bp);
+
+ len += logger->buffer_size;
+ offset += logger->buffer_size;
+
+ bnxt_fill_coredump_seg_hdr(bp, &seg_hdr, NULL, len,
+ 0, 0, 0, 13, seg_id);
+ memcpy(seg_hdr_dest, &seg_hdr, sizeof(seg_hdr));
+ seg_id++;
+ }
+ mtx_unlock(&bp->log_lock);
+ return (offset);
+}
+
+void
+bnxt_reset_loggers(struct bnxt_softc *bp)
+{
+ struct bnxt_logger *logger, *tmp;
+
+ mtx_lock(&bp->log_lock);
+ TAILQ_FOREACH_SAFE(logger, &bp->loggers_list, list, tmp) {
+ logger->head = 0;
+ logger->tail = 0;
+ logger->valid = false;
+ }
+ mtx_unlock(&bp->log_lock);
+}
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_log.h b/sys/dev/bnxt/bnxt_en/bnxt_log.h
new file mode 100644
index 000000000000..ad92065bf76d
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_log.h
@@ -0,0 +1,123 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BNXT_LOG_H
+#define BNXT_LOG_H
+
+#define BNXT_LOGGER_L2 1
+#define BNXT_LOGGER_ROCE 2
+
+#define BNXT_LOG_MSG_SIZE 256
+#define BNXT_LOG_NUM_BUFFERS(x) ((x) / BNXT_LOG_MSG_SIZE)
+
+struct bnxt_logger {
+ TAILQ_ENTRY(bnxt_logger) list;
+ uint16_t logger_id;
+ uint32_t buffer_size;
+ uint16_t head;
+ uint16_t tail;
+ bool valid;
+ void *msgs;
+ uint32_t live_max_size;
+ void *live_msgs;
+ uint32_t max_live_buff_size;
+ uint32_t live_msgs_len;
+ void (*log_live_op)(void *dev);
+};
+
+struct bnxt_coredump_segment_hdr {
+ uint8_t signature[4];
+ uint32_t component_id;
+ uint32_t segment_id;
+ uint32_t flags;
+ uint8_t low_version;
+ uint8_t high_version;
+ uint16_t function_id;
+ uint32_t offset;
+ uint32_t length;
+ uint32_t status;
+ uint32_t duration;
+ uint32_t data_offset;
+ uint32_t instance;
+ uint32_t rsvd[5];
+};
+
+struct bnxt_coredump_record {
+ uint8_t signature[4];
+ uint32_t flags;
+ uint8_t low_version;
+ uint8_t high_version;
+ uint8_t asic_state;
+ uint8_t rsvd0[5];
+ char system_name[32];
+ uint16_t year;
+ uint16_t month;
+ uint16_t day;
+ uint16_t hour;
+ uint16_t minute;
+ uint16_t second;
+ uint16_t utc_bias;
+ uint16_t rsvd1;
+ char commandline[256];
+ uint32_t total_segments;
+ uint32_t os_ver_major;
+ uint32_t os_ver_minor;
+ uint32_t rsvd2;
+ char os_name[32];
+ uint16_t end_year;
+ uint16_t end_month;
+ uint16_t end_day;
+ uint16_t end_hour;
+ uint16_t end_minute;
+ uint16_t end_second;
+ uint16_t end_utc_bias;
+ uint32_t asic_id1;
+ uint32_t asic_id2;
+ uint32_t coredump_status;
+ uint8_t ioctl_low_version;
+ uint8_t ioctl_high_version;
+ uint16_t rsvd3[313];
+};
+
+int bnxt_register_logger(struct bnxt_softc *bp, uint16_t logger_id,
+ uint32_t num_buffers, void (*log_live)(void *),
+ uint32_t live_size);
+void bnxt_unregister_logger(struct bnxt_softc *bp, int logger_id);
+void bnxt_log_add_msg(struct bnxt_softc *bp, uint16_t logger_id,
+ const char *format, ...);
+void bnxt_log_live(struct bnxt_softc *bp, uint16_t logger_id,
+ const char *format, ...);
+void bnxt_reset_loggers(struct bnxt_softc *bp);
+size_t bnxt_get_loggers_coredump_size(struct bnxt_softc *bp);
+int bnxt_start_logging_driver_coredump(struct bnxt_softc *bp, char *dest_buf);
+void bnxt_fill_coredump_seg_hdr(struct bnxt_softc *bp,
+ struct bnxt_coredump_segment_hdr *seg_hdr,
+ struct coredump_segment_record *seg_rec,
+ uint32_t seg_len, int status,
+ uint32_t duration, uint32_t instance,
+ uint32_t comp_id, uint32_t seg_id);
+#endif
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_log_data.c b/sys/dev/bnxt/bnxt_en/bnxt_log_data.c
new file mode 100644
index 000000000000..180cd72361a9
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_log_data.c
@@ -0,0 +1,78 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bnxt.h"
+#include "bnxt_hwrm.h"
+#include "bnxt_log.h"
+#include "bnxt_log_data.h"
+
+static void
+bnxt_log_drv_version(struct bnxt_softc *bp)
+{
+ bnxt_log_live(bp, BNXT_LOGGER_L2, "\n");
+
+ bnxt_log_live(bp, BNXT_LOGGER_L2, "Interface: L2 driver version: %s\n",
+ bnxt_driver_version);
+}
+
+static void
+bnxt_log_tx_sw_state(struct bnxt_softc *softc)
+{
+ int i;
+ uint32_t prod, cons;
+
+ for (i = 0; i < softc->ntxqsets; i++) {
+ bnxt_hwrm_ring_info_get(softc,
+ HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_TX, i, &prod, &cons);
+ bnxt_log_live(softc, BNXT_LOGGER_L2,
+ "tx {fw_ring: %d prod: %x cons: %x}\n",
+ i, prod, cons);
+ }
+}
+
+static void
+bnxt_log_rx_sw_state(struct bnxt_softc *softc)
+{
+ int i;
+ uint32_t prod, cons;
+
+ for (i = 0; i < softc->nrxqsets; i++) {
+ bnxt_hwrm_ring_info_get(softc,
+ HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_RX, i, &prod, &cons);
+ bnxt_log_live(softc, BNXT_LOGGER_L2,
+ "rx{fw_ring: %d prod: %x}\n", i, prod);
+ }
+
+}
+
+void
+bnxt_log_ring_states(struct bnxt_softc *bp)
+{
+ bnxt_log_drv_version(bp);
+ bnxt_log_tx_sw_state(bp);
+ bnxt_log_rx_sw_state(bp);
+}
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_log_data.h b/sys/dev/bnxt/bnxt_en/bnxt_log_data.h
new file mode 100644
index 000000000000..63b84ba7a7e4
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_log_data.h
@@ -0,0 +1,35 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2026 Broadcom Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BNXT_LOG_DATA_H
+#define BNXT_LOG_DATA_H
+
+#define BNXT_L2_MAX_LOG_BUFFERS 1024
+#define BNXT_L2_MAX_LIVE_LOG_SIZE (4 << 20)
+
+void bnxt_log_ring_states(struct bnxt_softc *bp);
+#endif