* [PATCH for-next 1/6] RDMA/hns: Add trace for flush CQE
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
@ 2025-04-18 8:56 ` Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 2/6] RDMA/hns: Add trace for WQE dumping Junxian Huang
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-18 8:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang
Add trace to print the producer index of QP when triggering flush CQE.
Output example:
$ cat /sys/kernel/debug/tracing/trace
tracer: nop
entries-in-buffer/entries-written: 2/2 #P:128
_-----=> irqs-off/BH-disabled
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / _-=> migrate-disable
|||| / delay
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
ib_send_bw-11474 [075] d..1. 2393.434738: sq_flush_cqe: SQ 0x2 flush head 0xb5c7.
ib_send_bw-11474 [075] d..1. 2393.434739: rq_flush_cqe: RQ 0x2 flush head 0.
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
drivers/infiniband/hw/hns/hns_roce_device.h | 17 +++++++
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 +++
drivers/infiniband/hw/hns/hns_roce_trace.h | 50 +++++++++++++++++++++
3 files changed, 72 insertions(+)
create mode 100644 drivers/infiniband/hw/hns/hns_roce_trace.h
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 560a1d9de408..080bd049b0f8 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -1027,6 +1027,23 @@ struct hns_roce_dev {
atomic64_t *dfx_cnt;
};
+enum hns_roce_trace_type {
+ TRACE_SQ,
+ TRACE_RQ,
+};
+
+static inline const char *trace_type_to_str(enum hns_roce_trace_type type)
+{
+ switch (type) {
+ case TRACE_SQ:
+ return "SQ";
+ case TRACE_RQ:
+ return "RQ";
+ default:
+ return "UNKNOWN";
+ }
+}
+
static inline struct hns_roce_dev *to_hr_dev(struct ib_device *ib_dev)
{
return container_of(ib_dev, struct hns_roce_dev, ib_dev);
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index c6399490e3a5..f29265f28ba9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -50,6 +50,9 @@
#include "hns_roce_hem.h"
#include "hns_roce_hw_v2.h"
+#define CREATE_TRACE_POINTS
+#include "hns_roce_trace.h"
+
enum {
CMD_RST_PRC_OTHERS,
CMD_RST_PRC_SUCCESS,
@@ -5312,6 +5315,7 @@ static void v2_set_flushed_fields(struct ib_qp *ibqp,
return;
spin_lock_irqsave(&hr_qp->sq.lock, sq_flag);
+ trace_sq_flush_cqe(hr_qp->qpn, hr_qp->sq.head, TRACE_SQ);
hr_reg_write(context, QPC_SQ_PRODUCER_IDX, hr_qp->sq.head);
hr_reg_clear(qpc_mask, QPC_SQ_PRODUCER_IDX);
hr_qp->state = IB_QPS_ERR;
@@ -5321,6 +5325,7 @@ static void v2_set_flushed_fields(struct ib_qp *ibqp,
return;
spin_lock_irqsave(&hr_qp->rq.lock, rq_flag);
+ trace_rq_flush_cqe(hr_qp->qpn, hr_qp->rq.head, TRACE_RQ);
hr_reg_write(context, QPC_RQ_PRODUCER_IDX, hr_qp->rq.head);
hr_reg_clear(qpc_mask, QPC_RQ_PRODUCER_IDX);
spin_unlock_irqrestore(&hr_qp->rq.lock, rq_flag);
diff --git a/drivers/infiniband/hw/hns/hns_roce_trace.h b/drivers/infiniband/hw/hns/hns_roce_trace.h
new file mode 100644
index 000000000000..104a4abf9177
--- /dev/null
+++ b/drivers/infiniband/hw/hns/hns_roce_trace.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2025 Hisilicon Limited.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hns_roce
+
+#if !defined(__HNS_ROCE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define __HNS_ROCE_TRACE_H
+
+#include <linux/tracepoint.h>
+#include "hns_roce_device.h"
+
+DECLARE_EVENT_CLASS(flush_head_template,
+ TP_PROTO(unsigned long qpn, u32 pi,
+ enum hns_roce_trace_type type),
+ TP_ARGS(qpn, pi, type),
+
+ TP_STRUCT__entry(__field(unsigned long, qpn)
+ __field(u32, pi)
+ __field(enum hns_roce_trace_type, type)
+ ),
+
+ TP_fast_assign(__entry->qpn = qpn;
+ __entry->pi = pi;
+ __entry->type = type;
+ ),
+
+ TP_printk("%s 0x%lx flush head 0x%x.",
+ trace_type_to_str(__entry->type),
+ __entry->qpn, __entry->pi)
+);
+
+DEFINE_EVENT(flush_head_template, sq_flush_cqe,
+ TP_PROTO(unsigned long qpn, u32 pi,
+ enum hns_roce_trace_type type),
+ TP_ARGS(qpn, pi, type));
+DEFINE_EVENT(flush_head_template, rq_flush_cqe,
+ TP_PROTO(unsigned long qpn, u32 pi,
+ enum hns_roce_trace_type type),
+ TP_ARGS(qpn, pi, type));
+
+#endif /* __HNS_ROCE_TRACE_H */
+
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hns_roce_trace
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#include <trace/define_trace.h>
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH for-next 2/6] RDMA/hns: Add trace for WQE dumping
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 1/6] RDMA/hns: Add trace for flush CQE Junxian Huang
@ 2025-04-18 8:56 ` Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 3/6] RDMA/hns: Add trace for AEQE dumping Junxian Huang
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-18 8:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang
Add trace for WQE dumping, including SQ, RQ and SRQ.
Output example:
$ cat /sys/kernel/debug/tracing/trace
tracer: nop
entries-in-buffer/entries-written: 2/2 #P:128
_-----=> irqs-off/BH-disabled
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / _-=> migrate-disable
|||| / delay
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
roce_test_main-22730 [074] d..1. 16133.898282: sq_wqe: SQ 0xc wqe
(0x0/0xffff0820a6076060): {0x180,0x639c,0x0,0x1000000,0x0,0x0,0x0,0x0,
0x639c,0x300,0xf7e38000,0x0,0x0,0x0,0x0,0x0}
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
drivers/infiniband/hw/hns/hns_roce_device.h | 3 ++
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 8 ++++
drivers/infiniband/hw/hns/hns_roce_trace.h | 44 +++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 080bd049b0f8..1dcc9cbb4678 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -1030,6 +1030,7 @@ struct hns_roce_dev {
enum hns_roce_trace_type {
TRACE_SQ,
TRACE_RQ,
+ TRACE_SRQ,
};
static inline const char *trace_type_to_str(enum hns_roce_trace_type type)
@@ -1039,6 +1040,8 @@ static inline const char *trace_type_to_str(enum hns_roce_trace_type type)
return "SQ";
case TRACE_RQ:
return "RQ";
+ case TRACE_SRQ:
+ return "SRQ";
default:
return "UNKNOWN";
}
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index f29265f28ba9..a86884cd1b25 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -741,6 +741,8 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
else
ret = set_ud_wqe(qp, wr, wqe, &sge_idx, owner_bit);
+ trace_sq_wqe(qp->qpn, wqe_idx, wqe, 1 << qp->sq.wqe_shift,
+ wr->wr_id, TRACE_SQ);
if (unlikely(ret)) {
*bad_wr = wr;
goto out;
@@ -810,6 +812,9 @@ static void fill_rq_wqe(struct hns_roce_qp *hr_qp, const struct ib_recv_wr *wr,
wqe = hns_roce_get_recv_wqe(hr_qp, wqe_idx);
fill_recv_sge_to_wqe(wr, wqe, max_sge, hr_qp->rq.rsv_sge);
+
+ trace_rq_wqe(hr_qp->qpn, wqe_idx, wqe, 1 << hr_qp->rq.wqe_shift,
+ wr->wr_id, TRACE_RQ);
}
static int hns_roce_v2_post_recv(struct ib_qp *ibqp,
@@ -987,6 +992,9 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
fill_recv_sge_to_wqe(wr, wqe, max_sge, srq->rsv_sge);
fill_wqe_idx(srq, wqe_idx);
srq->wrid[wqe_idx] = wr->wr_id;
+
+ trace_srq_wqe(srq->srqn, wqe_idx, wqe, 1 << srq->wqe_shift,
+ wr->wr_id, TRACE_SRQ);
}
if (likely(nreq)) {
diff --git a/drivers/infiniband/hw/hns/hns_roce_trace.h b/drivers/infiniband/hw/hns/hns_roce_trace.h
index 104a4abf9177..71da01b19916 100644
--- a/drivers/infiniband/hw/hns/hns_roce_trace.h
+++ b/drivers/infiniband/hw/hns/hns_roce_trace.h
@@ -41,6 +41,50 @@ DEFINE_EVENT(flush_head_template, rq_flush_cqe,
enum hns_roce_trace_type type),
TP_ARGS(qpn, pi, type));
+#define MAX_SGE_PER_WQE 64
+#define MAX_WQE_SIZE (MAX_SGE_PER_WQE * HNS_ROCE_SGE_SIZE)
+DECLARE_EVENT_CLASS(wqe_template,
+ TP_PROTO(unsigned long qpn, u32 idx, void *wqe, u32 len,
+ u64 id, enum hns_roce_trace_type type),
+ TP_ARGS(qpn, idx, wqe, len, id, type),
+
+ TP_STRUCT__entry(__field(unsigned long, qpn)
+ __field(u32, idx)
+ __array(__le32, wqe,
+ MAX_WQE_SIZE / sizeof(__le32))
+ __field(u32, len)
+ __field(u64, id)
+ __field(enum hns_roce_trace_type, type)
+ ),
+
+ TP_fast_assign(__entry->qpn = qpn;
+ __entry->idx = idx;
+ __entry->id = id;
+ memcpy(__entry->wqe, wqe, len);
+ __entry->len = len / sizeof(__le32);
+ __entry->type = type;
+ ),
+
+ TP_printk("%s 0x%lx wqe(0x%x/0x%llx): %s",
+ trace_type_to_str(__entry->type),
+ __entry->qpn, __entry->idx, __entry->id,
+ __print_array(__entry->wqe, __entry->len,
+ sizeof(__le32)))
+);
+
+DEFINE_EVENT(wqe_template, sq_wqe,
+ TP_PROTO(unsigned long qpn, u32 idx, void *wqe, u32 len, u64 id,
+ enum hns_roce_trace_type type),
+ TP_ARGS(qpn, idx, wqe, len, id, type));
+DEFINE_EVENT(wqe_template, rq_wqe,
+ TP_PROTO(unsigned long qpn, u32 idx, void *wqe, u32 len, u64 id,
+ enum hns_roce_trace_type type),
+ TP_ARGS(qpn, idx, wqe, len, id, type));
+DEFINE_EVENT(wqe_template, srq_wqe,
+ TP_PROTO(unsigned long qpn, u32 idx, void *wqe, u32 len, u64 id,
+ enum hns_roce_trace_type type),
+ TP_ARGS(qpn, idx, wqe, len, id, type));
+
#endif /* __HNS_ROCE_TRACE_H */
#undef TRACE_INCLUDE_FILE
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH for-next 3/6] RDMA/hns: Add trace for AEQE dumping
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 1/6] RDMA/hns: Add trace for flush CQE Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 2/6] RDMA/hns: Add trace for WQE dumping Junxian Huang
@ 2025-04-18 8:56 ` Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 4/6] RDMA/hns: Add trace for MR/MTR attribute dumping Junxian Huang
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-18 8:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang
Add trace for AEQE dumping.
Output example:
$ cat /sys/kernel/debug/tracing/trace
tracer: nop
entries-in-buffer/entries-written: 2/2 #P:128
_-----=> irqs-off/BH-disabled
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / _-=> migrate-disable
|||| / delay
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
<idle>-0 [120] d.h1. 7995.835587: ae_info: event 19 aeqe:
{0x80006013,0x0,0x0,0x10d2c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 +
drivers/infiniband/hw/hns/hns_roce_trace.h | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index a86884cd1b25..ae8c790d4211 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -6260,6 +6260,7 @@ static irqreturn_t hns_roce_v2_aeq_int(struct hns_roce_dev *hr_dev,
eq->sub_type = sub_type;
++eq->cons_index;
aeqe_found = IRQ_HANDLED;
+ trace_ae_info(event_type, aeqe, eq->eqe_size);
atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_AEQE_CNT]);
diff --git a/drivers/infiniband/hw/hns/hns_roce_trace.h b/drivers/infiniband/hw/hns/hns_roce_trace.h
index 71da01b19916..11b00564bfba 100644
--- a/drivers/infiniband/hw/hns/hns_roce_trace.h
+++ b/drivers/infiniband/hw/hns/hns_roce_trace.h
@@ -85,6 +85,25 @@ DEFINE_EVENT(wqe_template, srq_wqe,
enum hns_roce_trace_type type),
TP_ARGS(qpn, idx, wqe, len, id, type));
+TRACE_EVENT(ae_info,
+ TP_PROTO(int event_type, void *aeqe, unsigned int len),
+ TP_ARGS(event_type, aeqe, len),
+
+ TP_STRUCT__entry(__field(int, event_type)
+ __array(__le32, aeqe,
+ HNS_ROCE_V3_EQE_SIZE / sizeof(__le32))
+ __field(u32, len)
+ ),
+
+ TP_fast_assign(__entry->event_type = event_type;
+ __entry->len = len / sizeof(__le32);
+ memcpy(__entry->aeqe, aeqe, len);
+ ),
+
+ TP_printk("event %2d aeqe: %s", __entry->event_type,
+ __print_array(__entry->aeqe, __entry->len, sizeof(__le32)))
+);
+
#endif /* __HNS_ROCE_TRACE_H */
#undef TRACE_INCLUDE_FILE
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH for-next 4/6] RDMA/hns: Add trace for MR/MTR attribute dumping
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
` (2 preceding siblings ...)
2025-04-18 8:56 ` [PATCH for-next 3/6] RDMA/hns: Add trace for AEQE dumping Junxian Huang
@ 2025-04-18 8:56 ` Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 5/6] RDMA/hns: Include hnae3.h in hns_roce_hw_v2.h Junxian Huang
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-18 8:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang
Add trace for MR/MTR attribute dumping.
Output example:
$ cat /sys/kernel/debug/tracing/trace
tracer: nop
entries-in-buffer/entries-written: 2/2 #P:128
_-----=> irqs-off/BH-disabled
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / _-=> migrate-disable
|||| / delay
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
ib_send_bw-14751 [111] ..... 8763.823038: buf_attr: rg cnt:1,
pg_sft:0xc, mtt_only:no, rg 0 (sz:131072, hop:2), rg 1 (sz:0, hop:0),
rg 2 (sz:0, hop:0)
ib_send_bw-14751 [111] ..... 8763.823118: drv_mr:
iova:0xffffb2968000, size:131072, key:512, pd:1, pbl_hop:1, npages:4,
type:0, status:0
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
drivers/infiniband/hw/hns/hns_roce_mr.c | 3 +
drivers/infiniband/hw/hns/hns_roce_trace.h | 65 ++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 09da3496843b..a462a557b818 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -38,6 +38,7 @@
#include "hns_roce_device.h"
#include "hns_roce_cmd.h"
#include "hns_roce_hem.h"
+#include "hns_roce_trace.h"
static u32 hw_index_to_key(int ind)
{
@@ -159,6 +160,7 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
+ trace_drv_mr(mr);
if (mr->type != MR_TYPE_FRMR)
ret = hr_dev->hw->write_mtpt(hr_dev, mailbox->buf, mr);
else
@@ -1146,6 +1148,7 @@ int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
struct ib_device *ibdev = &hr_dev->ib_dev;
int ret;
+ trace_buf_attr(buf_attr);
/* The caller has its own buffer list and invokes the hns_roce_mtr_map()
* to finish the MTT configuration.
*/
diff --git a/drivers/infiniband/hw/hns/hns_roce_trace.h b/drivers/infiniband/hw/hns/hns_roce_trace.h
index 11b00564bfba..2e60ab5943af 100644
--- a/drivers/infiniband/hw/hns/hns_roce_trace.h
+++ b/drivers/infiniband/hw/hns/hns_roce_trace.h
@@ -10,6 +10,7 @@
#define __HNS_ROCE_TRACE_H
#include <linux/tracepoint.h>
+#include <linux/string_choices.h>
#include "hns_roce_device.h"
DECLARE_EVENT_CLASS(flush_head_template,
@@ -104,6 +105,70 @@ TRACE_EVENT(ae_info,
__print_array(__entry->aeqe, __entry->len, sizeof(__le32)))
);
+TRACE_EVENT(drv_mr,
+ TP_PROTO(struct hns_roce_mr *mr),
+ TP_ARGS(mr),
+
+ TP_STRUCT__entry(__field(u64, iova)
+ __field(u64, size)
+ __field(u32, key)
+ __field(u32, pd)
+ __field(u32, pbl_hop_num)
+ __field(u32, npages)
+ __field(int, type)
+ __field(int, enabled)
+ ),
+
+ TP_fast_assign(__entry->iova = mr->iova;
+ __entry->size = mr->size;
+ __entry->key = mr->key;
+ __entry->pd = mr->pd;
+ __entry->pbl_hop_num = mr->pbl_hop_num;
+ __entry->npages = mr->npages;
+ __entry->type = mr->type;
+ __entry->enabled = mr->enabled;
+ ),
+
+ TP_printk("iova:0x%llx, size:%llu, key:%u, pd:%u, pbl_hop:%u, npages:%u, type:%d, status:%d",
+ __entry->iova, __entry->size, __entry->key,
+ __entry->pd, __entry->pbl_hop_num, __entry->npages,
+ __entry->type, __entry->enabled)
+);
+
+TRACE_EVENT(buf_attr,
+ TP_PROTO(struct hns_roce_buf_attr *attr),
+ TP_ARGS(attr),
+
+ TP_STRUCT__entry(__field(unsigned int, region_count)
+ __field(unsigned int, region0_size)
+ __field(int, region0_hopnum)
+ __field(unsigned int, region1_size)
+ __field(int, region1_hopnum)
+ __field(unsigned int, region2_size)
+ __field(int, region2_hopnum)
+ __field(unsigned int, page_shift)
+ __field(bool, mtt_only)
+ ),
+
+ TP_fast_assign(__entry->region_count = attr->region_count;
+ __entry->region0_size = attr->region[0].size;
+ __entry->region0_hopnum = attr->region[0].hopnum;
+ __entry->region1_size = attr->region[1].size;
+ __entry->region1_hopnum = attr->region[1].hopnum;
+ __entry->region2_size = attr->region[2].size;
+ __entry->region2_hopnum = attr->region[2].hopnum;
+ __entry->page_shift = attr->page_shift;
+ __entry->mtt_only = attr->mtt_only;
+ ),
+
+ TP_printk("rg cnt:%u, pg_sft:0x%x, mtt_only:%s, rg 0 (sz:%u, hop:%u), rg 1 (sz:%u, hop:%u), rg 2 (sz:%u, hop:%u)\n",
+ __entry->region_count, __entry->page_shift,
+ str_yes_no(__entry->mtt_only),
+ __entry->region0_size, __entry->region0_hopnum,
+ __entry->region1_size, __entry->region1_hopnum,
+ __entry->region2_size, __entry->region2_hopnum)
+);
+
#endif /* __HNS_ROCE_TRACE_H */
#undef TRACE_INCLUDE_FILE
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH for-next 5/6] RDMA/hns: Include hnae3.h in hns_roce_hw_v2.h
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
` (3 preceding siblings ...)
2025-04-18 8:56 ` [PATCH for-next 4/6] RDMA/hns: Add trace for MR/MTR attribute dumping Junxian Huang
@ 2025-04-18 8:56 ` Junxian Huang
2025-04-18 8:56 ` [PATCH for-next 6/6] RDMA/hns: Add trace for CMDQ dumping Junxian Huang
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-18 8:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang
hns_roce_hw_v2.h has a direct dependency on hnae3.h due to the
inline function hns_roce_write64(), but it doesn't include this
header currently. This leads to that files including
hns_roce_hw_v2.h must also include hnae3.h to avoid compilation
errors, even if they themselves don't really rely on hnae3.h.
This doesn't make sense, hns_roce_hw_v2.h should include hnae3.h
directly.
Fixes: d3743fa94ccd ("RDMA/hns: Fix the chip hanging caused by sending doorbell during reset")
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
drivers/infiniband/hw/hns/hns_roce_ah.c | 1 -
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 -
drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 +
drivers/infiniband/hw/hns/hns_roce_main.c | 1 -
drivers/infiniband/hw/hns/hns_roce_restrack.c | 1 -
5 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c
index 4fc5b9d5fea8..307c35888b30 100644
--- a/drivers/infiniband/hw/hns/hns_roce_ah.c
+++ b/drivers/infiniband/hw/hns/hns_roce_ah.c
@@ -33,7 +33,6 @@
#include <linux/pci.h>
#include <rdma/ib_addr.h>
#include <rdma/ib_cache.h>
-#include "hnae3.h"
#include "hns_roce_device.h"
#include "hns_roce_hw_v2.h"
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index ae8c790d4211..78d39afb2aa0 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -43,7 +43,6 @@
#include <rdma/ib_umem.h>
#include <rdma/uverbs_ioctl.h>
-#include "hnae3.h"
#include "hns_roce_common.h"
#include "hns_roce_device.h"
#include "hns_roce_cmd.h"
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 91a5665465ff..bc7466830eaf 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -34,6 +34,7 @@
#define _HNS_ROCE_HW_V2_H
#include <linux/bitops.h>
+#include "hnae3.h"
#define HNS_ROCE_V2_MAX_RC_INL_INN_SZ 32
#define HNS_ROCE_V2_MTT_ENTRY_SZ 64
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index cf89a8db4f64..02f7acb30c5d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -37,7 +37,6 @@
#include <rdma/ib_smi.h>
#include <rdma/ib_user_verbs.h>
#include <rdma/ib_cache.h>
-#include "hnae3.h"
#include "hns_roce_common.h"
#include "hns_roce_device.h"
#include "hns_roce_hem.h"
diff --git a/drivers/infiniband/hw/hns/hns_roce_restrack.c b/drivers/infiniband/hw/hns/hns_roce_restrack.c
index 356d98816949..f637b73b946e 100644
--- a/drivers/infiniband/hw/hns/hns_roce_restrack.c
+++ b/drivers/infiniband/hw/hns/hns_roce_restrack.c
@@ -4,7 +4,6 @@
#include <rdma/rdma_cm.h>
#include <rdma/restrack.h>
#include <uapi/rdma/rdma_netlink.h>
-#include "hnae3.h"
#include "hns_roce_common.h"
#include "hns_roce_device.h"
#include "hns_roce_hw_v2.h"
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH for-next 6/6] RDMA/hns: Add trace for CMDQ dumping
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
` (4 preceding siblings ...)
2025-04-18 8:56 ` [PATCH for-next 5/6] RDMA/hns: Include hnae3.h in hns_roce_hw_v2.h Junxian Huang
@ 2025-04-18 8:56 ` Junxian Huang
2025-04-20 12:21 ` [PATCH for-next 0/6] RDMA/hns: Add trace support Leon Romanovsky
2025-04-20 15:11 ` Leon Romanovsky
7 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-18 8:56 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang
Add trace for CMDQ dumping.
Output example:
$ cat /sys/kernel/debug/tracing/trace
tracer: nop
entries-in-buffer/entries-written: 2/2 #P:128
_-----=> irqs-off/BH-disabled
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / _-=> migrate-disable
|||| / delay
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
kworker/u512:1-14003 [089] b..1. 50737.238304: cmdq_req: 0000:bd:00.0 cmdq opcode:0x8500, flag:0x1, retval:0x0, data:{0x2,0x0,0x0,0xffff0000,0x32323232,0x0}
kworker/u512:1-14003 [089] b..1. 50737.238316: cmdq_resp: 0000:bd:00.0 cmdq opcode:0x8500, flag:0x2, retval:0x0, data:{0x2,0x0,0x0,0xffff0000,0x32323232,0x0}
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++
drivers/infiniband/hw/hns/hns_roce_trace.h | 35 ++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 78d39afb2aa0..db33b4d329d1 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1321,6 +1321,8 @@ static int __hns_roce_cmq_send_one(struct hns_roce_dev *hr_dev,
tail = csq->head;
for (i = 0; i < num; i++) {
+ trace_cmdq_req(hr_dev, &desc[i]);
+
csq->desc[csq->head++] = desc[i];
if (csq->head == csq->desc_num)
csq->head = 0;
@@ -1335,6 +1337,8 @@ static int __hns_roce_cmq_send_one(struct hns_roce_dev *hr_dev,
if (hns_roce_cmq_csq_done(hr_dev)) {
ret = 0;
for (i = 0; i < num; i++) {
+ trace_cmdq_resp(hr_dev, &csq->desc[tail]);
+
/* check the result of hardware write back */
desc_ret = le16_to_cpu(csq->desc[tail++].retval);
if (tail == csq->desc_num)
diff --git a/drivers/infiniband/hw/hns/hns_roce_trace.h b/drivers/infiniband/hw/hns/hns_roce_trace.h
index 2e60ab5943af..adc3d66ce06c 100644
--- a/drivers/infiniband/hw/hns/hns_roce_trace.h
+++ b/drivers/infiniband/hw/hns/hns_roce_trace.h
@@ -12,6 +12,7 @@
#include <linux/tracepoint.h>
#include <linux/string_choices.h>
#include "hns_roce_device.h"
+#include "hns_roce_hw_v2.h"
DECLARE_EVENT_CLASS(flush_head_template,
TP_PROTO(unsigned long qpn, u32 pi,
@@ -169,6 +170,40 @@ TRACE_EVENT(buf_attr,
__entry->region2_size, __entry->region2_hopnum)
);
+DECLARE_EVENT_CLASS(cmdq,
+ TP_PROTO(struct hns_roce_dev *hr_dev,
+ struct hns_roce_cmq_desc *desc),
+ TP_ARGS(hr_dev, desc),
+
+ TP_STRUCT__entry(__string(dev_name, dev_name(hr_dev->dev))
+ __field(u16, opcode)
+ __field(u16, flag)
+ __field(u16, retval)
+ __array(__le32, data, 6)
+ ),
+
+ TP_fast_assign(__assign_str(dev_name);
+ __entry->opcode = le16_to_cpu(desc->opcode);
+ __entry->flag = le16_to_cpu(desc->flag);
+ __entry->retval = le16_to_cpu(desc->retval);
+ memcpy(__entry->data, desc->data, 6 * sizeof(__le32));
+ ),
+
+ TP_printk("%s cmdq opcode:0x%x, flag:0x%x, retval:0x%x, data:%s\n",
+ __get_str(dev_name), __entry->opcode,
+ __entry->flag, __entry->retval,
+ __print_array(__entry->data, 6, sizeof(__le32)))
+);
+
+DEFINE_EVENT(cmdq, cmdq_req,
+ TP_PROTO(struct hns_roce_dev *hr_dev,
+ struct hns_roce_cmq_desc *desc),
+ TP_ARGS(hr_dev, desc));
+DEFINE_EVENT(cmdq, cmdq_resp,
+ TP_PROTO(struct hns_roce_dev *hr_dev,
+ struct hns_roce_cmq_desc *desc),
+ TP_ARGS(hr_dev, desc));
+
#endif /* __HNS_ROCE_TRACE_H */
#undef TRACE_INCLUDE_FILE
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH for-next 0/6] RDMA/hns: Add trace support
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
` (5 preceding siblings ...)
2025-04-18 8:56 ` [PATCH for-next 6/6] RDMA/hns: Add trace for CMDQ dumping Junxian Huang
@ 2025-04-20 12:21 ` Leon Romanovsky
2025-04-21 12:20 ` Leon Romanovsky
2025-04-20 15:11 ` Leon Romanovsky
7 siblings, 1 reply; 11+ messages in thread
From: Leon Romanovsky @ 2025-04-20 12:21 UTC (permalink / raw)
To: jgg, Junxian Huang; +Cc: linux-rdma, linuxarm, tangchengchang
On Fri, 18 Apr 2025 16:56:41 +0800, Junxian Huang wrote:
> Add trace support for hns. Set tracepoints for flushe CQE, WQE,
> AEQE, MT/MTR and CMDQ.
>
> Patch #5 fixes the dependency issue of hns_roce_hw_v2.h on hnae3.h,
> otherwise there will be a compilation error when hns_roce_hw_v2.h
> is included in hns_roce_trace.h in patch #6.
>
> [...]
Applied, thanks!
[1/6] RDMA/hns: Add trace for flush CQE
https://git.kernel.org/rdma/rdma/c/96cb704b04419c
[2/6] RDMA/hns: Add trace for WQE dumping
https://git.kernel.org/rdma/rdma/c/cc1131a3004ed6
[3/6] RDMA/hns: Add trace for AEQE dumping
https://git.kernel.org/rdma/rdma/c/39091301472a12
[4/6] RDMA/hns: Add trace for MR/MTR attribute dumping
https://git.kernel.org/rdma/rdma/c/0f38b1359190fb
[5/6] RDMA/hns: Include hnae3.h in hns_roce_hw_v2.h
https://git.kernel.org/rdma/rdma/c/07474abfb48070
[6/6] RDMA/hns: Add trace for CMDQ dumping
https://git.kernel.org/rdma/rdma/c/6ce9c93102b98b
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH for-next 0/6] RDMA/hns: Add trace support
2025-04-20 12:21 ` [PATCH for-next 0/6] RDMA/hns: Add trace support Leon Romanovsky
@ 2025-04-21 12:20 ` Leon Romanovsky
0 siblings, 0 replies; 11+ messages in thread
From: Leon Romanovsky @ 2025-04-21 12:20 UTC (permalink / raw)
To: jgg, Junxian Huang; +Cc: linux-rdma, linuxarm, tangchengchang
On Sun, Apr 20, 2025 at 08:21:13AM -0400, Leon Romanovsky wrote:
>
> On Fri, 18 Apr 2025 16:56:41 +0800, Junxian Huang wrote:
> > Add trace support for hns. Set tracepoints for flushe CQE, WQE,
> > AEQE, MT/MTR and CMDQ.
> >
> > Patch #5 fixes the dependency issue of hns_roce_hw_v2.h on hnae3.h,
> > otherwise there will be a compilation error when hns_roce_hw_v2.h
> > is included in hns_roce_trace.h in patch #6.
> >
> > [...]
>
> Applied, thanks!
I dropped this.
Thanks
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH for-next 0/6] RDMA/hns: Add trace support
2025-04-18 8:56 [PATCH for-next 0/6] RDMA/hns: Add trace support Junxian Huang
` (6 preceding siblings ...)
2025-04-20 12:21 ` [PATCH for-next 0/6] RDMA/hns: Add trace support Leon Romanovsky
@ 2025-04-20 15:11 ` Leon Romanovsky
2025-04-21 13:01 ` Junxian Huang
7 siblings, 1 reply; 11+ messages in thread
From: Leon Romanovsky @ 2025-04-20 15:11 UTC (permalink / raw)
To: Junxian Huang; +Cc: jgg, linux-rdma, linuxarm, tangchengchang
On Fri, Apr 18, 2025 at 04:56:41PM +0800, Junxian Huang wrote:
> Add trace support for hns. Set tracepoints for flushe CQE, WQE,
> AEQE, MT/MTR and CMDQ.
>
> Patch #5 fixes the dependency issue of hns_roce_hw_v2.h on hnae3.h,
> otherwise there will be a compilation error when hns_roce_hw_v2.h
> is included in hns_roce_trace.h in patch #6.
>
> Junxian Huang (6):
> RDMA/hns: Add trace for flush CQE
> RDMA/hns: Add trace for WQE dumping
> RDMA/hns: Add trace for AEQE dumping
> RDMA/hns: Add trace for MR/MTR attribute dumping
> RDMA/hns: Include hnae3.h in hns_roce_hw_v2.h
> RDMA/hns: Add trace for CMDQ dumping
>
> drivers/infiniband/hw/hns/hns_roce_ah.c | 1 -
> drivers/infiniband/hw/hns/hns_roce_device.h | 20 ++
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 19 +-
> drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 +
> drivers/infiniband/hw/hns/hns_roce_main.c | 1 -
> drivers/infiniband/hw/hns/hns_roce_mr.c | 3 +
> drivers/infiniband/hw/hns/hns_roce_restrack.c | 1 -
> drivers/infiniband/hw/hns/hns_roce_trace.h | 213 ++++++++++++++++++
> 8 files changed, 255 insertions(+), 4 deletions(-)
> create mode 100644 drivers/infiniband/hw/hns/hns_roce_trace.h
Please change trace_drv_* calls to have a name of your driver, e.g.
trace_drv_mr() -> trace_hns_mr().
Thanks
>
> --
> 2.33.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH for-next 0/6] RDMA/hns: Add trace support
2025-04-20 15:11 ` Leon Romanovsky
@ 2025-04-21 13:01 ` Junxian Huang
0 siblings, 0 replies; 11+ messages in thread
From: Junxian Huang @ 2025-04-21 13:01 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: jgg, linux-rdma, linuxarm, tangchengchang
On 2025/4/20 23:11, Leon Romanovsky wrote:
> On Fri, Apr 18, 2025 at 04:56:41PM +0800, Junxian Huang wrote:
>> Add trace support for hns. Set tracepoints for flushe CQE, WQE,
>> AEQE, MT/MTR and CMDQ.
>>
>> Patch #5 fixes the dependency issue of hns_roce_hw_v2.h on hnae3.h,
>> otherwise there will be a compilation error when hns_roce_hw_v2.h
>> is included in hns_roce_trace.h in patch #6.
>>
>> Junxian Huang (6):
>> RDMA/hns: Add trace for flush CQE
>> RDMA/hns: Add trace for WQE dumping
>> RDMA/hns: Add trace for AEQE dumping
>> RDMA/hns: Add trace for MR/MTR attribute dumping
>> RDMA/hns: Include hnae3.h in hns_roce_hw_v2.h
>> RDMA/hns: Add trace for CMDQ dumping
>>
>> drivers/infiniband/hw/hns/hns_roce_ah.c | 1 -
>> drivers/infiniband/hw/hns/hns_roce_device.h | 20 ++
>> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 19 +-
>> drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 +
>> drivers/infiniband/hw/hns/hns_roce_main.c | 1 -
>> drivers/infiniband/hw/hns/hns_roce_mr.c | 3 +
>> drivers/infiniband/hw/hns/hns_roce_restrack.c | 1 -
>> drivers/infiniband/hw/hns/hns_roce_trace.h | 213 ++++++++++++++++++
>> 8 files changed, 255 insertions(+), 4 deletions(-)
>> create mode 100644 drivers/infiniband/hw/hns/hns_roce_trace.h
>
> Please change trace_drv_* calls to have a name of your driver, e.g.
> trace_drv_mr() -> trace_hns_mr().
>
Sure
> Thanks
>
>>
>> --
>> 2.33.0
>>
>>
^ permalink raw reply [flat|nested] 11+ messages in thread