Commit 48ffc152 authored by Junxian Huang's avatar Junxian Huang Committed by Leon Romanovsky
Browse files

RDMA/hns: Add trace for MR/MTR attribute dumping



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: hns_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: hns_mr:
iova:0xffffb2968000, size:131072, key:512, pd:1, pbl_hop:1, npages:4,
type:0, status:0

Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20250421132750.1363348-5-huangjunxian6@hisilicon.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 1e63e2f9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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_hns_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_hns_buf_attr(buf_attr);
	/* The caller has its own buffer list and invokes the hns_roce_mtr_map()
	 * to finish the MTT configuration.
	 */
+65 −0
Original line number Diff line number Diff line
@@ -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(hns_ae_info,
		      __print_array(__entry->aeqe, __entry->len, sizeof(__le32)))
);

TRACE_EVENT(hns_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(hns_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