Skip to contentSkip to conversation

RDMA/bnxt_re: Driver Debug Enhancements

PATCH In review Selvin Xavier 5 participants 15 messages Feb 20, 2025 – Apr 1, 2025

Subsystems (5)
lore
Share & tools
lore

Selvin Xavier

author maintainer
#0 lore raw

cover RDMA/bnxt_re: Driver Debug Enhancements

For debugging issues in the field, we need to track some of the resources destroyed in the past. This is primarily required for tracking certain QPs that encountered errors, leading to application exits. A framework has been implemented to save this information and retrieve it during coredump collection.

The Broadcom bnxt L2 driver supports collecting driver dumps using the ethtool -w option. This feature now also supports collecting coredump information from the bnxt_re auxiliary driver. Two new callbacks have been implemented to exchange dump information supported by the auxbus bnxt_re driver.

The bnxt_re driver caches certain hardware information before resources are destroyed in the HW. Additionally,
some resource information from the host is necessary
for gathering meaningful debug information. Both types of information are cached by the driver for a finite (1024 for now)
number of resources.

Please review and apply.

Thanks,
Selvin Xavier

Kashyap Desai (3):
RDMA/bnxt_re : Initialize the HW context dump collection RDMA/bnxt_re: Get the resource contexts from the HW RDMA/bnxt_re: Dump the HW context information

Michael Chan (2):
bnxt_en: Introduce ULP coredump callbacks
RDMA/bnxt_re: Support the dump infrastructure

Saravanan Vajravel (3):
RDMA/bnxt_re: Add support for collecting the Queue dumps RDMA/bnxt_re: Cache the QP information RDMA/bnxt_re: Dump the debug information in snapdump

Selvin Xavier (1):
RDMA/bnxt_re: Add support for changing the snap dump level

 drivers/infiniband/hw/bnxt_re/bnxt_re.h            |  75 ++++++
 drivers/infiniband/hw/bnxt_re/debugfs.c            |  49 ++++
 drivers/infiniband/hw/bnxt_re/ib_verbs.c           | 185 ++++++++++++-
 drivers/infiniband/hw/bnxt_re/ib_verbs.h           |  42 +++
 drivers/infiniband/hw/bnxt_re/main.c               | 290 ++++++++++++++++++++-
 drivers/infiniband/hw/bnxt_re/qplib_fp.c           |  47 +++-
 drivers/infiniband/hw/bnxt_re/qplib_fp.h           |  16 +-
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.c         |   2 +
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.h         |  12 +
 drivers/infiniband/hw/bnxt_re/qplib_res.h          |  14 +
 drivers/infiniband/hw/bnxt_re/qplib_sp.c           |  15 +-
 drivers/infiniband/hw/bnxt_re/qplib_sp.h           |   3 +-
 drivers/infiniband/hw/bnxt_re/roce_hsi.h           |   2 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c |  12 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c      |  57 ++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h      |  22 ++
 16 files changed, 817 insertions(+), 26 deletions(-)
Signature · 1 line
2.5.5
author maintainer
#1 lore raw

PATCH 1/9 RDMA/bnxt_re: Add support for collecting the Queue dumps

From: Saravanan Vajravel <[email protected]>

As part of enhancing the debug data collection, allocate few data structures to hold the resources after the queues are destroyed.

Initialize the data structures to capture the data. By default, driver will cache the info of the QPs that are in error state. The dump levels can be changed from debugfs hook in a later patch. Driver caches the info of the last 1024 entries only.

---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h | 64 +++++++++++++++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/main.c    | 18 ++++++++++
 2 files changed, 82 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +64 -0
index b33b04e..5818db1 100644
@@ -173,6 +173,67 @@ static inline bool bnxt_re_chip_gen_p7(u16 chip_num)
 		chip_num == CHIP_NUM_57608);
 }
 
+#define BNXT_RE_MAX_QDUMP_ENTRIES 1024
+
+struct qdump_qpinfo {
+	u32 id;
+	u32 dest_qpid;
+	u64 qp_handle;
+	u32 mtu;
+	u8  type;
+	u8  wqe_mode;
+	u8  state;
+	u8  is_user;
+	u64 scq_handle;
+	u64 rcq_handle;
+	u32 scq_id;
+	u32 rcq_id;
+};
+
+struct qdump_mrinfo {
+	int type;
+	u32 lkey;
+	u32 rkey;
+	u64 total_size;
+	u64 mr_handle;
+};
+
+struct qdump_element {
+	struct bnxt_qplib_pbl pbl[PBL_LVL_MAX];
+	enum bnxt_qplib_pbl_lvl level;
+	struct bnxt_qplib_hwq *hwq;
+	struct bnxt_re_dev *rdev;
+	struct ib_umem *umem;
+	bool is_user_qp;
+	char des[32];
+	char *buf;
+	size_t len;
+	u16 stride;
+	u32 prod;
+	u32 cons;
+};
+
+struct qdump_array {
+	struct qdump_qpinfo qpinfo;
+	struct qdump_mrinfo mrinfo;
+	bool valid;
+	bool is_mr;
+};
+
+struct bnxt_re_qdump_head {
+	struct qdump_array *qdump;
+	u32 max_elements;
+	struct mutex lock; /* lock qdump array elements */
+	u32 index;
+};
+
+enum {
+	BNXT_RE_SNAPDUMP_NONE = 0,
+	BNXT_RE_SNAPDUMP_ERR,
+	/* Add new entry before this */
+	BNXT_RE_SNAPDUMP_ALL
+};
+
 struct bnxt_re_dev {
 	struct ib_device		ibdev;
 	struct list_head		list;
@@ -232,6 +293,9 @@ struct bnxt_re_dev {
 	unsigned long			event_bitmap;
 	struct bnxt_qplib_cc_param	cc_param;
 	struct workqueue_struct		*dcb_wq;
+	/* Head to track all QP dump */
+	struct bnxt_re_qdump_head qdump_head;
+	u8 snapdump_dbg_lvl;
 	struct dentry                   *cc_config;
 	struct bnxt_re_dbg_cc_config_params *cc_config_params;
 };
drivers/infiniband/hw/bnxt_re/main.c +18 -0
index e9e4da4..87fdf69 100644
@@ -2008,6 +2008,11 @@ static void bnxt_re_free_nqr_mem(struct bnxt_re_dev *rdev)
 	rdev->nqr = NULL;
 }
 
+static void bnxt_re_clean_qdump(struct bnxt_re_dev *rdev)
+{
+	vfree(rdev->qdump_head.qdump);
+}
+
 static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type)
 {
 	u8 type;
@@ -2018,6 +2023,7 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type)
 	bnxt_re_net_unregister_async_event(rdev);
 	bnxt_re_uninit_dcb_wq(rdev);
 
+	bnxt_re_clean_qdump(rdev);
 	if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags))
 		cancel_delayed_work_sync(&rdev->worker);
 
@@ -2063,6 +2069,16 @@ static void bnxt_re_worker(struct work_struct *work)
 	schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000));
 }
 
+static void bnxt_re_init_qdump(struct bnxt_re_dev *rdev)
+{
+	rdev->qdump_head.max_elements = BNXT_RE_MAX_QDUMP_ENTRIES;
+	rdev->qdump_head.index = 0;
+	rdev->snapdump_dbg_lvl = BNXT_RE_SNAPDUMP_ERR;
+	mutex_init(&rdev->qdump_head.lock);
+	rdev->qdump_head.qdump = vzalloc(rdev->qdump_head.max_elements *
+					 sizeof(struct qdump_array));
+}
+
 static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
 {
 	struct bnxt_re_ring_attr rattr = {};
@@ -2235,6 +2251,8 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
 		hash_init(rdev->srq_hash);
 
 	bnxt_re_debugfs_add_pdev(rdev);
+	if (bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx))
+		bnxt_re_init_qdump(rdev);
 
 	bnxt_re_init_dcb_wq(rdev);
 	bnxt_re_net_register_async_event(rdev);
Signature · 1 line
2.5.5
author maintainer
#2 lore raw

PATCH 2/9 RDMA/bnxt_re: Cache the QP information

In reply to Selvin Xavier

From: Saravanan Vajravel <[email protected]>

Add routines to cache the information about the QP before destroying. This can be retrieved and used for further debugging.

The default behavior is to capture the QPs that are moved to error. The driver sets the flags to capture the dump from the error asynchronous event.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 67 ++++++++++++++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/ib_verbs.h | 42 ++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/main.c     |  8 +++-
 drivers/infiniband/hw/bnxt_re/qplib_fp.h |  7 ++++
 4 files changed, 123 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +67 -0
index 2de101d..060143e 100644
@@ -41,6 +41,7 @@
 #include <linux/pci.h>
 #include <linux/netdevice.h>
 #include <linux/if_ether.h>
+#include <linux/vmalloc.h>
 #include <net/addrconf.h>
 
 #include <rdma/ib_verbs.h>
@@ -954,6 +955,71 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
 	return rc;
 }
 
+static struct qdump_array *bnxt_re_get_next_qpdump(struct bnxt_re_dev *rdev)
+{
+	struct qdump_array *qdump;
+	u32 index;
+
+	index = rdev->qdump_head.index;
+	qdump = &rdev->qdump_head.qdump[index];
+	memset(qdump, 0, sizeof(*qdump));
+
+	index++;
+	index %= rdev->qdump_head.max_elements;
+	rdev->qdump_head.index = index;
+
+	return qdump;
+}
+
+/*
+ * bnxt_re_capture_qpdump - Capture snapshot of various queues of a QP.
+ * @qp	-	Pointer to QP for which data has to be collected
+ *
+ * This function will capture info about SQ/RQ/SCQ/RCQ of a QP which
+ * can be used to debug any issue
+ *
+ */
+void bnxt_re_capture_qpdump(struct bnxt_re_qp *qp)
+{
+	struct bnxt_qplib_qp *qpl = &qp->qplib_qp;
+	struct bnxt_re_dev *rdev = qp->rdev;
+	struct qdump_qpinfo *qpinfo;
+	struct qdump_array *qdump;
+	bool capture_snapdump;
+
+	if (rdev->snapdump_dbg_lvl == BNXT_RE_SNAPDUMP_NONE)
+		return;
+
+	capture_snapdump = test_bit(QP_FLAGS_CAPTURE_SNAPDUMP, &qpl->flags);
+	if (rdev->snapdump_dbg_lvl == BNXT_RE_SNAPDUMP_ERR &&
+	    !capture_snapdump)
+		return;
+
+	if (qp->is_snapdump_captured || !rdev->qdump_head.qdump)
+		return;
+
+	mutex_lock(&rdev->qdump_head.lock);
+	qdump = bnxt_re_get_next_qpdump(rdev);
+
+	qpinfo = &qdump->qpinfo;
+	qpinfo->id = qpl->id;
+	qpinfo->dest_qpid = qpl->dest_qpn;
+	qpinfo->is_user = qpl->is_user;
+	qpinfo->mtu = qpl->mtu;
+	qpinfo->state = qpl->state;
+	qpinfo->type = qpl->type;
+	qpinfo->wqe_mode = qpl->wqe_mode;
+	qpinfo->qp_handle = qpl->qp_handle;
+	qpinfo->scq_handle = qp->scq->qplib_cq.cq_handle;
+	qpinfo->rcq_handle = qp->rcq->qplib_cq.cq_handle;
+	qpinfo->scq_id = qp->scq->qplib_cq.id;
+	qpinfo->rcq_id = qp->rcq->qplib_cq.id;
+
+	qdump->valid = true;
+	qp->is_snapdump_captured = true;
+	mutex_unlock(&rdev->qdump_head.lock);
+}
+
 /* Queue Pairs */
 int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
 {
@@ -965,6 +1031,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
 	unsigned int flags;
 	int rc;
 
+	bnxt_re_capture_qpdump(qp);
 	bnxt_re_debug_rem_qpinfo(rdev, qp);
 
 	bnxt_qplib_flush_cqn_wq(&qp->qplib_qp);
drivers/infiniband/hw/bnxt_re/ib_verbs.h +42 -0

60 lines not on this page · raw message

drivers/infiniband/hw/bnxt_re/main.c +7 -1
index 87fdf69..67d2bf0 100644
@@ -1420,9 +1420,15 @@ static int bnxt_re_handle_qp_async_event(struct creq_qp_event *qp_event,
 	struct ib_event event = {};
 	unsigned int flags;
 
-	if (qp->qplib_qp.srq)
+	if (qp->qplib_qp.srq) {
 		srq =  container_of(qp->qplib_qp.srq, struct bnxt_re_srq,
 				    qplib_srq);
+		set_bit(SRQ_FLAGS_CAPTURE_SNAPDUMP, &srq->qplib_srq.flags);
+	}
+
+	set_bit(QP_FLAGS_CAPTURE_SNAPDUMP, &qp->qplib_qp.flags);
+	set_bit(CQ_FLAGS_CAPTURE_SNAPDUMP, &qp->scq->qplib_cq.flags);
+	set_bit(CQ_FLAGS_CAPTURE_SNAPDUMP, &qp->rcq->qplib_cq.flags);
 
 	if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR &&
 	    rdma_is_kernel_res(&qp->ib_qp.res)) {
drivers/infiniband/hw/bnxt_re/qplib_fp.h +7 -0
index 0d9487c..d1acb01 100644
@@ -106,6 +106,8 @@ struct bnxt_qplib_srq {
 	u16				eventq_hw_ring_id;
 	spinlock_t			lock; /* protect SRQE link list */
 	u8				toggle;
+	unsigned long			flags;
+#define SRQ_FLAGS_CAPTURE_SNAPDUMP	1
 };
 
 struct bnxt_qplib_sge {
@@ -279,6 +281,8 @@ struct bnxt_qplib_qp {
 	u8				wqe_mode;
 	u8				state;
 	u8				cur_qp_state;
+	u16				ctx_size_sb;
+	u8				is_user;
 	u64				modify_flags;
 	u32				max_inline_data;
 	u32				mtu;
@@ -344,6 +348,8 @@ struct bnxt_qplib_qp {
 	u32				msn_tbl_sz;
 	bool				is_host_msn_tbl;
 	u8				tos_dscp;
+	unsigned long			flags;
+#define QP_FLAGS_CAPTURE_SNAPDUMP	1
 };
 
 #define BNXT_QPLIB_MAX_CQE_ENTRY_SIZE	sizeof(struct cq_base)
@@ -448,6 +454,7 @@ struct bnxt_qplib_cq {
 #define CQ_RESIZE_WAIT_TIME_MS		500
 	unsigned long			flags;
 #define CQ_FLAGS_RESIZE_IN_PROG		1
+#define CQ_FLAGS_CAPTURE_SNAPDUMP	2
 	wait_queue_head_t		waitq;
 	struct list_head		sqf_head, rqf_head;
 	atomic_t			arm_state;
Signature · 1 line
2.5.5
author maintainer
#3 lore raw

PATCH 3/9 RDMA/bnxt_re : Initialize the HW context dump collection

In reply to Selvin Xavier

From: Kashyap Desai <[email protected]>

HW context of the destroyed resources are returned during the destroy operation of the resource. Initialize the data structures to collect the HW contexts. Check if the FW supports the context dump and initialize the FW to send the dump to host.

---
 drivers/infiniband/hw/bnxt_re/main.c       | 32 ++++++++++++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.c |  2 ++
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 12 +++++++++++
 drivers/infiniband/hw/bnxt_re/qplib_res.h  | 14 +++++++++++++
 drivers/infiniband/hw/bnxt_re/roce_hsi.h   |  2 ++
 5 files changed, 62 insertions(+)
drivers/infiniband/hw/bnxt_re/main.c +32 -0
index 67d2bf0..6b5a169 100644
@@ -2016,6 +2016,12 @@ static void bnxt_re_free_nqr_mem(struct bnxt_re_dev *rdev)
 
 static void bnxt_re_clean_qdump(struct bnxt_re_dev *rdev)
 {
+	struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw;
+
+	vfree(rcfw->qp_ctxm_data);
+	vfree(rcfw->cq_ctxm_data);
+	vfree(rcfw->srq_ctxm_data);
+	vfree(rcfw->mrw_ctxm_data);
 	vfree(rdev->qdump_head.qdump);
 }
 
@@ -2075,14 +2081,40 @@ static void bnxt_re_worker(struct work_struct *work)
 	schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000));
 }
 
+static void bnxt_re_init_ctxm_size(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw;
+
+	if (bnxt_qplib_is_chip_gen_p7(rdev->chip_ctx)) {
+		rcfw->qp_ctxm_size = BNXT_RE_CONTEXT_TYPE_QPC_SIZE_P7;
+		rcfw->cq_ctxm_size = BNXT_RE_CONTEXT_TYPE_CQ_SIZE_P7;
+		rcfw->srq_ctxm_size = BNXT_RE_CONTEXT_TYPE_SRQ_SIZE_P7;
+		rcfw->mrw_ctxm_size = BNXT_RE_CONTEXT_TYPE_MRW_SIZE_P7;
+
+	} else if (bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) {
+		rcfw->qp_ctxm_size = BNXT_RE_CONTEXT_TYPE_QPC_SIZE_P5;
+		rcfw->cq_ctxm_size = BNXT_RE_CONTEXT_TYPE_CQ_SIZE_P5;
+		rcfw->srq_ctxm_size = BNXT_RE_CONTEXT_TYPE_SRQ_SIZE_P5;
+		rcfw->mrw_ctxm_size = BNXT_RE_CONTEXT_TYPE_MRW_SIZE_P5;
+	}
+}
+
 static void bnxt_re_init_qdump(struct bnxt_re_dev *rdev)
 {
+	struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw;
+
 	rdev->qdump_head.max_elements = BNXT_RE_MAX_QDUMP_ENTRIES;
 	rdev->qdump_head.index = 0;
 	rdev->snapdump_dbg_lvl = BNXT_RE_SNAPDUMP_ERR;
 	mutex_init(&rdev->qdump_head.lock);
 	rdev->qdump_head.qdump = vzalloc(rdev->qdump_head.max_elements *
 					 sizeof(struct qdump_array));
+	/* Setup Context cache information */
+	bnxt_re_init_ctxm_size(rdev);
+	rcfw->qp_ctxm_data = vzalloc(BNXT_RE_MAX_QDUMP_ENTRIES * rcfw->qp_ctxm_size);
+	rcfw->cq_ctxm_data = vzalloc(BNXT_RE_MAX_QDUMP_ENTRIES * rcfw->cq_ctxm_size);
+	rcfw->srq_ctxm_data = vzalloc(BNXT_RE_MAX_QDUMP_ENTRIES * rcfw->srq_ctxm_size);
+	rcfw->mrw_ctxm_data = vzalloc(BNXT_RE_MAX_QDUMP_ENTRIES * rcfw->mrw_ctxm_size);
 }
 
 static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +2 -0
index 17e62f2..435b01f 100644
@@ -903,6 +903,8 @@ int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw,
 		flags |= CMDQ_INITIALIZE_FW_FLAGS_OPTIMIZE_MODIFY_QP_SUPPORTED;
 	if (rcfw->res->en_dev->flags & BNXT_EN_FLAG_ROCE_VF_RES_MGMT)
 		flags |= CMDQ_INITIALIZE_FW_FLAGS_L2_VF_RESOURCE_MGMT;
+	if (is_roce_context_destroy_sb_enabled(rcfw->res->dattr->dev_cap_flags2))
+		flags |= CMDQ_INITIALIZE_FW_FLAGS_DESTROY_CONTEXT_SB_SUPPORTED;
 	req.flags |= cpu_to_le16(flags);
 	req.stat_ctx_id = cpu_to_le32(ctx->stats.fw_id);
 	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req), sizeof(resp), 0);
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h +12 -0
index 88814cb..155e24f 100644
@@ -228,6 +228,18 @@ struct bnxt_qplib_rcfw {
 	struct bnxt_qplib_qp_node *qp_tbl;
 	/* To synchronize the qp-handle hash table */
 	spinlock_t			tbl_lock;
+	u32 qp_ctxm_data_index;
+	u32 cq_ctxm_data_index;
+	u32 mrw_ctxm_data_index;
+	u32 srq_ctxm_data_index;
+	u16 qp_ctxm_size;
+	u16 cq_ctxm_size;
+	u16 mrw_ctxm_size;
+	u16 srq_ctxm_size;
+	void *qp_ctxm_data;
+	void *cq_ctxm_data;
+	void *mrw_ctxm_data;
+	void *srq_ctxm_data;
 	u64 oos_prev;
 	u32 init_oos_stats;
 	u32 cmdq_depth;
drivers/infiniband/hw/bnxt_re/qplib_res.h +14 -0
index be5d907..93200ea 100644
@@ -592,4 +592,18 @@ static inline bool _is_cq_coalescing_supported(u16 dev_cap_ext_flags2)
 	return dev_cap_ext_flags2 & CREQ_QUERY_FUNC_RESP_SB_CQ_COALESCING_SUPPORTED;
 }
 
+static inline bool is_roce_context_destroy_sb_enabled(u16 dev_cap_ext_flags2)
+{
+	return !!(dev_cap_ext_flags2 & CREQ_QUERY_FUNC_RESP_SB_DESTROY_CONTEXT_SB_SUPPORTED);
+}
+
+#define BNXT_RE_CONTEXT_TYPE_QPC_SIZE_P5	1088
+#define BNXT_RE_CONTEXT_TYPE_CQ_SIZE_P5		128
+#define BNXT_RE_CONTEXT_TYPE_MRW_SIZE_P5	128
+#define BNXT_RE_CONTEXT_TYPE_SRQ_SIZE_P5	192
+
+#define BNXT_RE_CONTEXT_TYPE_QPC_SIZE_P7	1088
+#define BNXT_RE_CONTEXT_TYPE_CQ_SIZE_P7		192
+#define BNXT_RE_CONTEXT_TYPE_MRW_SIZE_P7	192
+#define BNXT_RE_CONTEXT_TYPE_SRQ_SIZE_P7	192
 #endif /* __BNXT_QPLIB_RES_H__ */
drivers/infiniband/hw/bnxt_re/roce_hsi.h +2 -0
index 0ee60fd..041e9ac 100644
@@ -218,6 +218,7 @@ struct cmdq_initialize_fw {
 	#define CMDQ_INITIALIZE_FW_FLAGS_HW_REQUESTER_RETX_SUPPORTED     0x2UL
 	#define CMDQ_INITIALIZE_FW_FLAGS_OPTIMIZE_MODIFY_QP_SUPPORTED    0x8UL
 	#define CMDQ_INITIALIZE_FW_FLAGS_L2_VF_RESOURCE_MGMT		 0x10UL
+	#define CMDQ_INITIALIZE_FW_FLAGS_DESTROY_CONTEXT_SB_SUPPORTED               0x20UL
 	__le16	cookie;
 	u8	resp_size;
 	u8	reserved8;
@@ -2215,6 +2216,7 @@ struct creq_query_func_resp_sb {
 	#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_IQM_MSN_TABLE   (0x2UL << 4)
 	#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_LAST	\
 			CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_IQM_MSN_TABLE
+	#define CREQ_QUERY_FUNC_RESP_SB_DESTROY_CONTEXT_SB_SUPPORTED             0x100UL
 	#define CREQ_QUERY_FUNC_RESP_SB_MIN_RNR_RTR_RTS_OPT_SUPPORTED            0x1000UL
 	__le16	max_xp_qp_size;
 	__le16	create_qp_batch_size;
Signature · 1 line
2.5.5
author maintainer
#4 lore raw

PATCH 4/9 RDMA/bnxt_re: Get the resource contexts from the HW

In reply to Selvin Xavier

From: Kashyap Desai <[email protected]>

While destroying the resources like QP/CQ/SRQ/MRs, FW sends the contexts to the host. Driver caches these information to be dumped later for debugging. Driver can hold the information of the last 1024 entries of each resources.

---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h  |   9 +++
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 120 +++++++++++++++++++++++++++----
 drivers/infiniband/hw/bnxt_re/qplib_fp.c |  47 +++++++++++-
 drivers/infiniband/hw/bnxt_re/qplib_fp.h |   9 ++-
 drivers/infiniband/hw/bnxt_re/qplib_sp.c |  15 +++-
 drivers/infiniband/hw/bnxt_re/qplib_sp.h |   3 +-
 6 files changed, 181 insertions(+), 22 deletions(-)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +9 -0
index 5818db1..45601635 100644
@@ -175,6 +175,15 @@ static inline bool bnxt_re_chip_gen_p7(u16 chip_num)
 
 #define BNXT_RE_MAX_QDUMP_ENTRIES 1024
 
+enum {
+	BNXT_RE_RES_TYPE_CQ = 0,
+	BNXT_RE_RES_TYPE_UCTX,
+	BNXT_RE_RES_TYPE_QP,
+	BNXT_RE_RES_TYPE_SRQ,
+	BNXT_RE_RES_TYPE_MR,
+	BNXT_RE_RES_TYPE_MAX
+};
+
 struct qdump_qpinfo {
 	u32 id;
 	u32 dest_qpid;
drivers/infiniband/hw/bnxt_re/ib_verbs.c +106 -14

238 lines not on this page · raw message

drivers/infiniband/hw/bnxt_re/qplib_fp.c +44 -3

117 lines not on this page · raw message

drivers/infiniband/hw/bnxt_re/qplib_fp.h +6 -3
index d1acb01..1710b59 100644
@@ -555,14 +555,16 @@ int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res,
 int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,
 			 struct bnxt_qplib_srq *srq);
 void bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
-			    struct bnxt_qplib_srq *srq);
+			    struct bnxt_qplib_srq *srq,
+			    u16 sb_resp_size, void *sb_resp_va);
 int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
 			     struct bnxt_qplib_swqe *wqe);
 int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
 int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
 int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
 int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
-int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp,
+			  u16 ctx_size, void *ctx_sb_data);
 void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp);
 void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res,
 			    struct bnxt_qplib_qp *qp);
@@ -584,7 +586,8 @@ int bnxt_qplib_resize_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
 			 int new_cqes);
 void bnxt_qplib_resize_cq_complete(struct bnxt_qplib_res *res,
 				   struct bnxt_qplib_cq *cq);
-int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
+int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
+			  u16 sb_resp_size, void *sb_resp_v);
 int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
 		       int num, struct bnxt_qplib_qp **qp);
 bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq);
drivers/infiniband/hw/bnxt_re/qplib_sp.c +14 -1
index 4ccd440..d2c519d 100644
@@ -504,10 +504,12 @@ int bnxt_qplib_destroy_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah,
 }
 
 /* MRW */
-int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw)
+int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
+			u16 sb_resp_size, void *sb_resp_va)
 {
 	struct creq_deallocate_key_resp resp = {};
 	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct bnxt_qplib_rcfw_sbuf sbuf = {};
 	struct cmdq_deallocate_key req = {};
 	struct bnxt_qplib_cmdqmsg msg = {};
 	int rc;
@@ -517,6 +519,11 @@ int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw)
 		return 0;
 	}
 
+	if (sb_resp_size && sb_resp_va) {
+		sbuf.size = sb_resp_size;
+		sbuf.sb = dma_alloc_coherent(&rcfw->pdev->dev, sbuf.size,
+					     &sbuf.dma_addr, GFP_KERNEL);
+	}
 	bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)&req,
 				 CMDQ_BASE_OPCODE_DEALLOCATE_KEY,
 				 sizeof(req));
@@ -530,12 +537,18 @@ int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw)
 	else
 		req.key = cpu_to_le32(mrw->lkey);
 
+	req.resp_addr = cpu_to_le64(sbuf.dma_addr);
+	req.resp_size = sb_resp_size / BNXT_QPLIB_CMDQE_UNITS;
 	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
 				sizeof(resp), 0);
 	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
 	if (rc)
 		return rc;
 
+	if (sbuf.sb) {
+		memcpy(sb_resp_va, sbuf.sb, sb_resp_size);
+		dma_free_coherent(&rcfw->pdev->dev, sbuf.size, sbuf.sb, sbuf.dma_addr);
+	}
 	/* Free the qplib's MRW memory */
 	if (mrw->hwq.max_elements)
 		bnxt_qplib_free_hwq(res, &mrw->hwq);
drivers/infiniband/hw/bnxt_re/qplib_sp.h +2 -1
index e626b05..728b1f1 100644
@@ -340,7 +340,8 @@ int bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
 			 bool block);
 int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
 		      struct ib_umem *umem, int num_pbls, u32 buf_pg_size);
-int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr);
+int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+			u16 ctx_size, void *ctx_sb_data);
 int bnxt_qplib_alloc_fast_reg_mr(struct bnxt_qplib_res *res,
 				 struct bnxt_qplib_mrw *mr, int max);
 int bnxt_qplib_alloc_fast_reg_page_list(struct bnxt_qplib_res *res,
Signature · 1 line
2.5.5
author maintainer
#5 lore raw

PATCH 5/9 bnxt_en: Introduce ULP coredump callbacks

In reply to Selvin Xavier

From: Michael Chan <[email protected]>

Add .ulp_get_dump_info() and .ulp_get_dump_data() callbacks to struct bnxt_ulp_ops. When ethtool -w is invoked to get the coredump, these 2 callbacks to the bnxt_re auxbus driver will be called if they are populated by the bnxt_re driver. The first callback gets the number of coredump segments and the size of each coredump segment. The 2nd callback copies the coredump data for each segment.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c | 12 ++++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c      | 57 ++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h      | 22 +++++++++
 3 files changed, 89 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +10 -2
index 7236d8e..2106d0d 100644
@@ -14,6 +14,7 @@
 #include "bnxt.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_coredump.h"
+#include "bnxt_ulp.h"
 
 static const u16 bnxt_bstore_to_seg_id[] = {
 	[BNXT_CTX_QP]			= BNXT_CTX_MEM_SEG_QP,
@@ -414,13 +415,20 @@ static int __bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf,
 	}
 
 	if (dump_type == BNXT_DUMP_DRIVER) {
-		u32 drv_len, segs = 0;
+		u32 drv_len, drv_segs, segs = 0;
+		void *drv_buf = NULL;
 
 		drv_len = bnxt_get_ctx_coredump(bp, buf, offset, &segs);
+		drv_segs = segs;
+		segs = 0;
+		if (buf)
+			drv_buf = buf + offset + drv_len;
+		drv_len += bnxt_get_ulp_dump(bp, dump_type, drv_buf, &segs);
+		drv_segs += segs;
 		*dump_len += drv_len;
 		offset += drv_len;
 		if (buf)
-			coredump.total_segs += segs;
+			coredump.total_segs += drv_segs;
 		goto err;
 	}
 
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +57 -0

69 lines not on this page · raw message

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h +22 -0
index 7fa3b8d..9298589 100644
@@ -29,11 +29,31 @@ struct bnxt_msix_entry {
 	u32	db_offset;
 };
 
+#define BNXT_ULP_MAX_DUMP_SEGS	8
+
+/**
+ * struct bnxt_ulp_dump - bnxt ULP aux device coredump info
+ * @segs:	number of coredump segments with info in the seg_tbl
+ * @seg_tbl:	coredump segment table
+ * @seg_tbl.seg_id:	coredump segment ID
+ * @seg_tbl.seg_len:	coredump segment len
+ */
+struct bnxt_ulp_dump {
+	u32	segs;
+	struct bnxt_ulp_dump_tbl {
+		u32	seg_id;
+		u32	seg_len;
+	} seg_tbl[BNXT_ULP_MAX_DUMP_SEGS];
+};
+
 struct bnxt_ulp_ops {
 	/* async_notifier() cannot sleep (in BH context) */
 	void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
 	void (*ulp_irq_stop)(void *, bool);
 	void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
+	void (*ulp_get_dump_info)(void *handle, u32 dump_flags,
+				  struct bnxt_ulp_dump *dump);
+	void (*ulp_get_dump_data)(void *handle, u32 seg_id, void *buf, u32 len);
 };
 
 struct bnxt_fw_msg {
@@ -51,6 +71,7 @@ struct bnxt_ulp {
 	u16		max_async_event_id;
 	u16		msix_requested;
 	atomic_t	ref_count;
+	struct bnxt_ulp_dump	ulp_dump;
 };
 
 struct bnxt_en_dev {
@@ -119,6 +140,7 @@ void bnxt_ulp_start(struct bnxt *bp, int err);
 void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
 void bnxt_ulp_irq_stop(struct bnxt *bp);
 void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
+u32 bnxt_get_ulp_dump(struct bnxt *bp, u32 dump_flag, void *buf, u32 *segs);
 void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
 void bnxt_rdma_aux_device_uninit(struct bnxt *bp);
 void bnxt_rdma_aux_device_del(struct bnxt *bp);
Signature · 1 line
2.5.5
maintainer Acked-by on v1 5/9
#6 lore raw

Re: [PATCH rdma-next 5/9] bnxt_en: Introduce ULP coredump callbacks

Quoted 8 lines · On Thu, 20 Feb 2025 10:34:52 -0800 Selvin Xavier wrote:

From: Michael Chan <[email protected]>

Add .ulp_get_dump_info() and .ulp_get_dump_data() callbacks to struct bnxt_ulp_ops. When ethtool -w is invoked to get the coredump, these 2 callbacks to the bnxt_re auxbus driver will be called if they are populated by the bnxt_re driver. The first callback gets the number of coredump segments and the size of each coredump segment. The 2nd callback copies the coredump data for each segment.

Signature · 1 line
pw-bot: nap
author maintainer
#7 lore raw

PATCH 6/9 RDMA/bnxt_re: Support the dump infrastructure

In reply to Selvin Xavier

From: Michael Chan <[email protected]>

Adds the stubs for the debug dump in bnxt_re
driver.
Each segment of the dump data holds a particalar resource type. get_dump_info returns the number of segments and the size of each segments. Driver currently supports segments for QP/CQ/SRQ/MR and for the generic host logs.

While taking the dump, get_dump_data will be invoked for each of the segments and bnxt_re driver returns the data associated with each segment.

---
 drivers/infiniband/hw/bnxt_re/main.c | 85 +++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/main.c +84 -1
index 6b5a169..76dd0fa 100644
@@ -497,10 +497,93 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
 	}
 }
 
+#define BNXT_SEGMENT_ROCE	255
+#define BNXT_SEGMENT_QP_CTX	256
+#define BNXT_SEGMENT_SRQ_CTX	257
+#define BNXT_SEGMENT_CQ_CTX	258
+#define BNXT_SEGMENT_MR_CTX	270
+
+static void bnxt_re_dump_ctx(struct bnxt_re_dev *rdev, u32 seg_id, void *buf,
+			     u32 buf_len)
+{
+}
+
+/* bnxt_re_snapdump - Collect RoCE debug data for coredump.
+ * @rdev	-   rdma device instance
+ * @buf		-	Pointer to dump buffer
+ * @buf_len	-	Buffer length
+ *
+ * This function will dump RoCE debug data to the coredump.
+ *
+ * Returns: Nothing
+ *
+ */
+static void bnxt_re_snapdump(struct bnxt_re_dev *rdev, void *buf, u32 buf_len)
+{
+}
+
+#define BNXT_RE_TRACE_DUMP_SIZE	0x2000000
+
+/* bnxt_re_get_dump_info - ULP callback from L2 driver to collect dump info
+ * @handle	- en_dev information. L2 and RoCE device information
+ * @dump_flags	- ethtool dump flags
+ * @dump	- ulp structure containing all coredump segment info
+ *
+ * This function is the callback from the L2 driver to provide the list of
+ * dump segments for the ethtool coredump.
+ *
+ * Returns: Nothing
+ *
+ */
+static void bnxt_re_get_dump_info(void *handle, u32 dump_flags,
+				  struct bnxt_ulp_dump *dump)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
+	struct bnxt_ulp_dump_tbl *tbl = dump->seg_tbl;
+	struct bnxt_re_dev *rdev = en_info->rdev;
+
+	dump->segs = 5;
+	tbl[0].seg_id = BNXT_SEGMENT_QP_CTX;
+	tbl[0].seg_len = rdev->rcfw.qp_ctxm_size * BNXT_RE_MAX_QDUMP_ENTRIES;
+	tbl[1].seg_id = BNXT_SEGMENT_CQ_CTX;
+	tbl[1].seg_len = rdev->rcfw.cq_ctxm_size * BNXT_RE_MAX_QDUMP_ENTRIES;
+	tbl[2].seg_id = BNXT_SEGMENT_MR_CTX;
+	tbl[2].seg_len = rdev->rcfw.mrw_ctxm_size * BNXT_RE_MAX_QDUMP_ENTRIES;
+	tbl[3].seg_id = BNXT_SEGMENT_SRQ_CTX;
+	tbl[3].seg_len = rdev->rcfw.srq_ctxm_size * BNXT_RE_MAX_QDUMP_ENTRIES;
+	tbl[4].seg_id = BNXT_SEGMENT_ROCE;
+	tbl[4].seg_len = BNXT_RE_TRACE_DUMP_SIZE;
+}
+
+/* bnxt_re_get_dump_data - ULP callback from L2 driver to collect dump data
+ * @handle	- en_dev information. L2 and RoCE device information
+ * @seg_id	- segment ID of the dump
+ * @buf		- dump buffer pointer
+ * @len		- length of the buffer
+ *
+ * This function is the callback from the L2 driver to fill the buffer with
+ * coredump data for each segment.
+ *
+ * Returns: Nothing
+ *
+ */
+static void bnxt_re_get_dump_data(void *handle, u32 seg_id, void *buf, u32 len)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
+	struct bnxt_re_dev *rdev = en_info->rdev;
+
+	if (seg_id == BNXT_SEGMENT_ROCE)
+		return bnxt_re_snapdump(rdev, buf, len);
+
+	bnxt_re_dump_ctx(rdev, seg_id, buf, len);
+}
+
 static struct bnxt_ulp_ops bnxt_re_ulp_ops = {
 	.ulp_async_notifier = bnxt_re_async_notifier,
 	.ulp_irq_stop = bnxt_re_stop_irq,
-	.ulp_irq_restart = bnxt_re_start_irq
+	.ulp_irq_restart = bnxt_re_start_irq,
+	.ulp_get_dump_info = bnxt_re_get_dump_info,
+	.ulp_get_dump_data = bnxt_re_get_dump_data,
 };
 
 /* RoCE -> Net driver */
Signature · 1 line
2.5.5
author maintainer
#8 lore raw

PATCH 7/9 RDMA/bnxt_re: Dump the debug information in snapdump

In reply to Selvin Xavier

From: Saravanan Vajravel <[email protected]>

Dump the cached debug information when the L2 driver invokes the get_dump_data hook.

---
 drivers/infiniband/hw/bnxt_re/main.c | 109 +++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/infiniband/hw/bnxt_re/main.c +109 -0
index 76dd0fa..afde0ef 100644
@@ -508,6 +508,106 @@ static void bnxt_re_dump_ctx(struct bnxt_re_dev *rdev, u32 seg_id, void *buf,
 {
 }
 
+/*
+ * bnxt_re_snapdump_qp - Log QP dump to the coredump buffer
+ * @rdev	-	Pointer to RoCE device instance
+ * @buf		-	Pointer to dump buffer
+ * @buf_len	-	Buffer length
+ *
+ * This function will invoke ULP logger to capture snapshot of
+ * SQ/RQ/SCQ/RCQ of a QP in ASCII format.
+ *
+ * Returns: Buffer length
+ */
+static u32 bnxt_re_snapdump_qp(struct bnxt_re_dev *rdev, void *buf, u32 buf_len)
+{
+	u32 index, len = 0, count = 0;
+	struct qdump_qpinfo *qpinfo;
+	struct qdump_array *qdump;
+
+	if (!rdev->qdump_head.qdump)
+		return 0;
+
+	mutex_lock(&rdev->qdump_head.lock);
+	index = rdev->qdump_head.index;
+	while (count < rdev->qdump_head.max_elements) {
+		count++;
+		index = (!index) ? (rdev->qdump_head.max_elements - 1) : (index - 1);
+		qdump = &rdev->qdump_head.qdump[index];
+		if (!qdump->valid || qdump->is_mr)
+			continue;
+
+		qpinfo = &qdump->qpinfo;
+		len += snprintf(buf + len, buf_len - len,
+				"qp_handle 0x%.8x 0x%.8x (xid %d) dest_qp %d type %s state %s ",
+				(u32)(qpinfo->qp_handle >> 32),
+				(u32)(qpinfo->qp_handle & 0xFFFFFFFF),
+				qpinfo->id, qpinfo->dest_qpid,
+				__to_qp_type_str(qpinfo->type),
+				__to_qp_state_str(qpinfo->state));
+		len += snprintf(buf + len, buf_len - len,
+				"is_usr %d scq_handle 0x%llx rcq_handle 0x%llx",
+				qpinfo->is_user, qpinfo->scq_handle, qpinfo->rcq_handle);
+		len += snprintf(buf + len, buf_len - len,
+				"scq_id %d rcq_id %d\n",
+				qpinfo->scq_id, qpinfo->rcq_id);
+		if (len >= buf_len)
+			goto dump_full;
+
+		if (len >= buf_len)
+			goto dump_full;
+	}
+	mutex_unlock(&rdev->qdump_head.lock);
+	return len;
+
+dump_full:
+	mutex_unlock(&rdev->qdump_head.lock);
+	return buf_len;
+}
+
+/*
+ * bnxt_re_snapdump_mr - Log PBL of MR to the coredump buffer
+ * @rdev	-	Pointer to RoCE device instance
+ * @buf		-	Pointer to dump buffer
+ * @buf_len	-	Buffer length
+ *
+ * This function will invoke ULP logger to capture PBL list of
+ * Memory Region in ASCII format.
+ *
+ * Returns: Buffer length
+ */
+static u32 bnxt_re_snapdump_mr(struct bnxt_re_dev *rdev, void *buf, u32 buf_len)
+{
+	u32 index, count = 0, len = 0;
+	struct qdump_array *qdump;
+
+	if (!rdev->qdump_head.qdump)
+		return 0;
+
+	mutex_lock(&rdev->qdump_head.lock);
+	index = rdev->qdump_head.index;
+	while (count < rdev->qdump_head.max_elements) {
+		count++;
+		index = (!index) ? (rdev->qdump_head.max_elements - 1) : (index - 1);
+		qdump = &rdev->qdump_head.qdump[index];
+		if (!qdump->valid || !qdump->is_mr)
+			continue;
+
+		len += snprintf(buf + len, buf_len - len,
+				"**MemoryRegion: type %d lkey 0x%x rkey 0x%x tot_sz %llu **\n",
+				qdump->mrinfo.type, qdump->mrinfo.lkey,
+				qdump->mrinfo.rkey, qdump->mrinfo.total_size);
+		if (len >= buf_len)
+			goto dump_full;
+	}
+	mutex_unlock(&rdev->qdump_head.lock);
+	return len;
+
+dump_full:
+	mutex_unlock(&rdev->qdump_head.lock);
+	return buf_len;
+}
+
 /* bnxt_re_snapdump - Collect RoCE debug data for coredump.
  * @rdev	-   rdma device instance
  * @buf		-	Pointer to dump buffer
@@ -520,6 +620,15 @@ static void bnxt_re_dump_ctx(struct bnxt_re_dev *rdev, u32 seg_id, void *buf,
  */
 static void bnxt_re_snapdump(struct bnxt_re_dev *rdev, void *buf, u32 buf_len)
 {
+	u32 len = 0;
+
+	len += bnxt_re_snapdump_qp(rdev, buf + len, buf_len - len);
+	if (len >= buf_len)
+		return;
+
+	len += bnxt_re_snapdump_mr(rdev, buf + len, buf_len - len);
+	if (len >= buf_len)
+		return;
 }
 
 #define BNXT_RE_TRACE_DUMP_SIZE	0x2000000
Signature · 1 line
2.5.5
author maintainer
#9 lore raw

PATCH 8/9 RDMA/bnxt_re: Dump the HW context information

In reply to Selvin Xavier

From: Kashyap Desai <[email protected]>

Dump the cached HW context information for QP/CQ/SRQ/MRs when the L2 driver queries using get_dump_data

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 10 ++++-----
 drivers/infiniband/hw/bnxt_re/main.c     | 38 ++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 6 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +4 -6
index a1ee6ca..dca435e 100644
@@ -1079,7 +1079,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
 	struct bnxt_qplib_nq *rcq_nq = NULL;
 	unsigned int flags;
 	void  *ctx_sb_data = NULL;
-	bool do_snapdump;
+	bool do_snapdump = false;
 	u16 ctx_size;
 	int rc;
 
@@ -1087,17 +1087,15 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
 	bnxt_re_debug_rem_qpinfo(rdev, qp);
 
 	bnxt_qplib_flush_cqn_wq(&qp->qplib_qp);
-	ctx_size = qplib_qp->ctx_size_sb;
+	ctx_size = rdev->rcfw.qp_ctxm_size;
 	if (ctx_size)
 		ctx_sb_data = vzalloc(ctx_size);
-	do_snapdump = test_bit(QP_FLAGS_CAPTURE_SNAPDUMP, &qplib_qp->flags);
 
 	rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp, ctx_size, ctx_sb_data);
 	if (rc)
 		ibdev_err(&rdev->ibdev, "Failed to destroy HW QP");
-	else
-		bnxt_re_save_resource_context(rdev, ctx_sb_data,
-					      BNXT_RE_RES_TYPE_QP, do_snapdump);
+	do_snapdump = test_bit(QP_FLAGS_CAPTURE_SNAPDUMP, &qplib_qp->flags);
+	bnxt_re_save_resource_context(rdev, ctx_sb_data,  BNXT_RE_RES_TYPE_QP, do_snapdump);
 
 	vfree(ctx_sb_data);
 	if (rdma_is_kernel_res(&qp->ib_qp.res)) {
drivers/infiniband/hw/bnxt_re/main.c +38 -0
index afde0ef..b2bf0d0 100644
@@ -506,6 +506,44 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
 static void bnxt_re_dump_ctx(struct bnxt_re_dev *rdev, u32 seg_id, void *buf,
 			     u32 buf_len)
 {
+	int ctx_index, i;
+	void *ctx_data;
+	u16 ctx_size;
+
+	switch (seg_id) {
+	case BNXT_SEGMENT_QP_CTX:
+		ctx_data = rdev->rcfw.qp_ctxm_data;
+		ctx_size = rdev->rcfw.qp_ctxm_size;
+		ctx_index = rdev->rcfw.qp_ctxm_data_index;
+		break;
+	case BNXT_SEGMENT_CQ_CTX:
+		ctx_data = rdev->rcfw.cq_ctxm_data;
+		ctx_size = rdev->rcfw.cq_ctxm_size;
+		ctx_index = rdev->rcfw.cq_ctxm_data_index;
+		break;
+	case BNXT_SEGMENT_MR_CTX:
+		ctx_data = rdev->rcfw.mrw_ctxm_data;
+		ctx_size = rdev->rcfw.mrw_ctxm_size;
+		ctx_index = rdev->rcfw.mrw_ctxm_data_index;
+		break;
+	case BNXT_SEGMENT_SRQ_CTX:
+		ctx_data = rdev->rcfw.srq_ctxm_data;
+		ctx_size = rdev->rcfw.srq_ctxm_size;
+		ctx_index = rdev->rcfw.srq_ctxm_data_index;
+		break;
+	default:
+		return;
+	}
+
+	if (!ctx_data || (ctx_size * BNXT_RE_MAX_QDUMP_ENTRIES) > buf_len)
+		return;
+
+	for (i = ctx_index; i < BNXT_RE_MAX_QDUMP_ENTRIES + ctx_index; i++) {
+		memcpy(buf, ctx_data + ((i % BNXT_RE_MAX_QDUMP_ENTRIES) * ctx_size),
+		       ctx_size);
+		buf += ctx_size;
+	}
+
 }
 
 /*
Signature · 1 line
2.5.5
author maintainer
#10 lore raw

PATCH 9/9 RDMA/bnxt_re: Add support for changing the snap dump level

In reply to Selvin Xavier

Add support for changing the default debug dump level.

---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h |  2 ++
 drivers/infiniband/hw/bnxt_re/debugfs.c | 49 +++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +2 -0
index 45601635..45d62f6 100644
@@ -304,6 +304,8 @@ struct bnxt_re_dev {
 	struct workqueue_struct		*dcb_wq;
 	/* Head to track all QP dump */
 	struct bnxt_re_qdump_head qdump_head;
+	struct dentry                   *tunables;
+	struct dentry                   *snapdump_dbg;
 	u8 snapdump_dbg_lvl;
 	struct dentry                   *cc_config;
 	struct bnxt_re_dbg_cc_config_params *cc_config_params;
drivers/infiniband/hw/bnxt_re/debugfs.c +49 -0

61 lines not on this page · raw message

Signature · 1 line
2.5.5
#11 lore raw
In reply to Selvin Xavier
Quoted 6 lines · Selvin Xavier

For debugging issues in the field, we need to track some of the resources destroyed in the past. This is primarily required for tracking certain QPs that encountered errors, leading to application exits. A framework has been implemented to save this information and retrieve it during coredump collection.

Quoted 8 lines

The Broadcom bnxt L2 driver supports collecting driver dumps using the ethtool -w option. This feature now also supports collecting coredump information from the bnxt_re auxiliary driver. Two new callbacks have been implemented to exchange dump information supported by the auxbus bnxt_re driver.

The bnxt_re driver caches certain hardware information before resources are destroyed in the HW.

Unfortunately, no. The idea that you will cache kernel objects and they live beyond their HW counterpart doesn't fit RDMA object model.

I'm aware that you are not keeping objects itself, but their shadow copy. So if you want, your FW can store these failed objects and you will retrieve them through existing netdev side (ethtool -w ...).

Thanks

author maintainer
#12 lore raw
Quoted 14 lines · Leon Romanovsky
Quoted 12 lines · Selvin Xavier

For debugging issues in the field, we need to track some of the resources destroyed in the past. This is primarily required for tracking certain QPs that encountered errors, leading to application exits. A framework has been implemented to save this information and retrieve it during coredump collection.

The Broadcom bnxt L2 driver supports collecting driver dumps using the ethtool -w option. This feature now also supports collecting coredump information from the bnxt_re auxiliary driver. Two new callbacks have been implemented to exchange dump information supported by the auxbus bnxt_re driver.

Quoted 5 lines
Quoted 2 lines

The bnxt_re driver caches certain hardware information before resources are destroyed in the HW.

Unfortunately, no. The idea that you will cache kernel objects and they live beyond their HW counterpart doesn't fit RDMA object model.

Since the scale of the resources are in thousands usually, we can not dump the debug information to the system logs. So we are not having much context of the failure and this is the reason for having this new mechanism.

Quoted 4 lines

I'm aware that you are not keeping objects itself, but their shadow copy. So if you want, your FW can store these failed objects and you will retrieve them through existing netdev side (ethtool -w ...).

FW doesn't have enough memory to backup this info. It needs to
be backed up in the host memory and FW has to write it to host memory when an error happens. This is possible in some newer FW versions. But itt is not just the HW context that we are caching here. We need to backup some host side driver/lib info also to correlate with the HW context. We have been debugging issues like this using our Out of box driver and we find it useful to get the context
of failure. Some of the internal tools can decode this information and we want to
have the same behavior between inbox and Out of Box driver.

Quoted 2 lines

Thanks

#13 lore raw
Quoted 4 lines · Selvin Xavier
Quoted 3 lines

I'm aware that you are not keeping objects itself, but their shadow copy. So if you want, your FW can store these failed objects and you will retrieve them through existing netdev side (ethtool -w ...).

Quoted 10 lines

FW doesn't have enough memory to backup this info. It needs to
be backed up in the host memory and FW has to write it to host memory when an error happens. This is possible in some newer FW versions. But itt is not just the HW context that we are caching here. We need to backup some host side driver/lib info also to correlate with the HW context. We have been debugging issues like this using our Out of box driver and we find it useful to get the context
of failure. Some of the internal tools can decode this information and we want to
have the same behavior between inbox and Out of Box driver.

Can you run some kind of daemon in userspace to collect this information in real time, maybe using fwctl or something instead of having the driver capture it?

Jason

#14 lore raw
Quoted 17 lines · Jason Gunthorpe
Quoted 4 lines · Selvin Xavier
Quoted 3 lines

I'm aware that you are not keeping objects itself, but their shadow copy. So if you want, your FW can store these failed objects and you will retrieve them through existing netdev side (ethtool -w ...).

Quoted 10 lines

FW doesn't have enough memory to backup this info. It needs to
be backed up in the host memory and FW has to write it to host memory when an error happens. This is possible in some newer FW versions. But itt is not just the HW context that we are caching here. We need to backup some host side driver/lib info also to correlate with the HW context. We have been debugging issues like this using our Out of box driver and we find it useful to get the context
of failure. Some of the internal tools can decode this information and we want to
have the same behavior between inbox and Out of Box driver.

Quoted 4 lines

Can you run some kind of daemon in userspace to collect this information in real time, maybe using fwctl or something instead of having the driver capture it?

Looking at a real-time log is exactly what we are doing. We have support for infrastructure to do that already so just adding this log would not be too difficult.