From: Sizhe Liu <liusizhe5@huawei•com>
To: <rostedt@goodmis•org>, <mhiramat@kernel•org>,
<mathieu.desnoyers@efficios•com>, <corbet@lwn•net>,
<skhan@linuxfoundation•org>, <bhelgaas@google•com>,
<yangyccccc@gmail•com>, <jic23@kernel•org>,
<john.g.garry@oracle•com>, <will@kernel•org>,
<james.clark@linaro•org>, <mike.leach@arm•com>,
<leo.yan@linux•dev>, <peterz@infradead•org>, <mingo@redhat•com>,
<acme@kernel•org>, <namhyung@kernel•org>, <mark.rutland@arm•com>,
<alexander.shishkin@linux•intel.com>, <jolsa@kernel•org>,
<irogers@google•com>, <adrian.hunter@intel•com>,
<wangyushan12@huawei•com>, <shenyang39@huawei•com>,
<gaozhihao6@h-partners•com>, <yuzhichengcheng@h-partners•com>,
<liyihang9@h-partners•com>
Cc: <linux-kernel@vger•kernel.org>, <linux-pci@vger•kernel.org>,
<linux-perf-users@vger•kernel.org>,
<linux-arm-kernel@lists•infradead.org>,
<linux-doc@vger•kernel.org>, <linuxarm@huawei•com>,
<prime.zeng@hisilicon•com>, <fanghao11@huawei•com>,
<wuyifan50@huawei•com>, <liusizhe5@huawei•com>
Subject: [PATCH 09/10] perf hisi-ptt: Add field-level parsing for header DW2/DW3
Date: Thu, 4 Jun 2026 15:50:04 +0800 [thread overview]
Message-ID: <20260604075005.2219785-10-liusizhe5@huawei.com> (raw)
In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com>
Add detailed field parsing for TLP header DW2 and DW3 based on the
message type parsed from header DW0:
- HEADER DW0: fields printed in 4DW format, printed as generic label
in 8DW format for compatibility.
- HEADER DW1: printed with the field name for both 4DW and 8DW formats.
- HEADER DW2: fields printed for MWr/Msg/Atomic/IO TLPs, generic label
for others.
- HEADER DW3: fields printed for Completion and Configuration TLPs,
generic label for others.
This gives users more structured information when analysing PTT
trace data.
Signed-off-by: Sizhe Liu <liusizhe5@huawei•com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 161 +++++++++++++++++-
1 file changed, 152 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
index 59ab8ec3a03d..46f11d5719ac 100644
--- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
+++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
@@ -38,6 +38,21 @@
* DW1 [ Header DW1 ]
* DW2 [ Header DW2 ]
* DW3 [ Header DW3 ]
+ *
+ * Header DW2 for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr is like:
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|----------------|----|---|--|-----------|----------|
+ * fields [Reserved][Request Segment][RSV][TV][T][Tag<13:10>][Header DW2]
+ *
+ * Header DW3 for CfgRd0/CfgWr0/CfgRd1/CfgWr1 is like:
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|--------------------|----|---|--|-----------|----------|
+ * fields [Reserved][Destination Segment][DSV][TV][T][Tag<13:10>][Header DW3]
+ *
+ * Header DW3 for Cpl/CplD/CplLk/CplDlk is like:
+ * bits [ 31:24 ][ 23:16 ][15][ 14:6 ][5][4][ 3:0 ]
+ * |--------------------|------------------|----|---------|--|---|----------|
+ * fields [Destination Segment][Completer Segment][DSV][Reserved][TV][T][Tag<13:10>]
*/
enum hisi_ptt_8dw_pkt_field_type {
@@ -127,6 +142,45 @@ union hisi_ptt_field_data {
uint32_t type : 5;
uint32_t format : 3;
} dw0_8dw;
+ /*
+ * Header DW2 for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr TLPs.
+ * Affects both 4DW and 8DW format.
+ */
+ struct {
+ uint32_t header_dw2 : 16;
+ uint32_t tag : 4;
+ uint32_t t : 1;
+ uint32_t tv : 1;
+ uint32_t rsv : 1;
+ uint32_t request_segment : 8;
+ uint32_t reserved : 1;
+ } dw2_mixed;
+ /*
+ * Header DW3 for CfgRd0/CfgWr0/CfgRd1/CfgWr1 TLPs.
+ * Affects both 4DW and 8DW format.
+ */
+ struct {
+ uint32_t header_dw3 : 16;
+ uint32_t tag : 4;
+ uint32_t t : 1;
+ uint32_t tv : 1;
+ uint32_t dsv : 1;
+ uint32_t destination_segment : 8;
+ uint32_t reserved : 1;
+ } dw3_cfg;
+ /*
+ * Header DW3 for Cpl/CplD/CplLk/CplDlk TLPs.
+ * Affects both 4DW and 8DW format.
+ */
+ struct {
+ uint32_t tag : 4;
+ uint32_t t : 1;
+ uint32_t tv : 1;
+ uint32_t reserved : 9;
+ uint32_t dsv : 1;
+ uint32_t completer_segment : 8;
+ uint32_t destination_segment : 8;
+ } dw3_cpl;
uint32_t value;
};
@@ -211,6 +265,85 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
+static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *color = PERF_COLOR_BLUE;
+ union hisi_ptt_field_data dw;
+
+ dw.value = le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos));
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw.value);
+ color_fprintf(stdout, color, " %s\n",
+ pkt_buf->pkt_type == HISI_PTT_4DW_PKT ?
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD1] :
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD1]);
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
+static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *color = PERF_COLOR_BLUE;
+ union hisi_ptt_field_data dw;
+
+ dw.value = le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos));
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw.value);
+
+ if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_MWR ||
+ pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_MSG ||
+ pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_ATOM ||
+ pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_IO)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Reserved", dw.dw2_mixed.reserved,
+ "Request Segment", dw.dw2_mixed.request_segment,
+ "RSV", dw.dw2_mixed.rsv, "TV", dw.dw2_mixed.tv,
+ "T", dw.dw2_mixed.t, "Tag", dw.dw2_mixed.tag,
+ "Header DW2", dw.dw2_mixed.header_dw2);
+ else
+ color_fprintf(stdout, color, " %s\n",
+ pkt_buf->pkt_type == HISI_PTT_4DW_PKT ?
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD2] :
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD2]);
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
+static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *color = PERF_COLOR_BLUE;
+ union hisi_ptt_field_data dw;
+
+ dw.value = le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos));
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw.value);
+
+ if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_CPL)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Destination Segment",
+ dw.dw3_cpl.destination_segment,
+ "Completer Segment", dw.dw3_cpl.completer_segment,
+ "DSV", dw.dw3_cpl.dsv,
+ "Reserved", dw.dw3_cpl.reserved,
+ "TV", dw.dw3_cpl.tv, "T", dw.dw3_cpl.t,
+ "Tag", dw.dw3_cpl.tag);
+ else if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_CFG)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Reserved", dw.dw3_cfg.reserved,
+ "Destination Segment",
+ dw.dw3_cfg.destination_segment,
+ "DSV", dw.dw3_cfg.dsv, "TV", dw.dw3_cfg.tv,
+ "T", dw.dw3_cfg.t, "Tag", dw.dw3_cfg.tag,
+ "Header DW3", dw.dw3_cfg.header_dw3);
+ else
+ color_fprintf(stdout, color, " %s\n",
+ pkt_buf->pkt_type == HISI_PTT_4DW_PKT ?
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD3] :
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD3]);
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
@@ -222,12 +355,24 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
continue;
}
- if (i == HISI_PTT_8DW_HEAD0) {
+ switch (i) {
+ case HISI_PTT_8DW_HEAD0:
hisi_ptt_print_head0(pkt_buf);
- continue;
+ break;
+ case HISI_PTT_8DW_HEAD1:
+ hisi_ptt_print_head1(pkt_buf);
+ break;
+ case HISI_PTT_8DW_HEAD2:
+ hisi_ptt_print_head2(pkt_buf);
+ break;
+ case HISI_PTT_8DW_HEAD3:
+ hisi_ptt_print_head3(pkt_buf);
+ break;
+ default:
+ hisi_ptt_print_pkt(pkt_buf,
+ hisi_ptt_8dw_pkt_field_name[i]);
+ break;
}
-
- hisi_ptt_print_pkt(pkt_buf, hisi_ptt_8dw_pkt_field_name[i]);
}
return hisi_ptt_pkt_size[HISI_PTT_8DW_PKT];
@@ -235,12 +380,10 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
- int i;
-
hisi_ptt_print_head0(pkt_buf);
-
- for (i = HISI_PTT_4DW_HEAD1; i < HISI_PTT_4DW_TYPE_MAX; i++)
- hisi_ptt_print_pkt(pkt_buf, hisi_ptt_4dw_pkt_field_name[i]);
+ hisi_ptt_print_head1(pkt_buf);
+ hisi_ptt_print_head2(pkt_buf);
+ hisi_ptt_print_head3(pkt_buf);
return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT];
}
--
2.33.0
next prev parent reply other threads:[~2026-06-04 7:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 7:49 [PATCH 00/10] perf hisi-ptt: Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-06-04 7:49 ` [PATCH 01/10] perf hisi-ptt: Fix spelling and abbreviation errors Sizhe Liu
2026-06-04 7:49 ` [PATCH 02/10] perf hisi-ptt: Fix PTT trace TLP Header parsing Sizhe Liu
2026-06-04 7:49 ` [PATCH 03/10] perf hisi-ptt: Rename hisi_ptt_4dw union for reuse Sizhe Liu
2026-06-04 7:49 ` [PATCH 04/10] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-06-04 7:50 ` [PATCH 05/10] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
2026-06-04 7:50 ` [PATCH 06/10] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
2026-06-04 7:50 ` [PATCH 07/10] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
2026-06-04 7:50 ` [PATCH 08/10] perf hisi-ptt: Add parsing of supported message types Sizhe Liu
2026-06-04 7:50 ` Sizhe Liu [this message]
2026-06-04 7:50 ` [PATCH 10/10] perf hisi-ptt: Add decoder version compatibility Sizhe Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260604075005.2219785-10-liusizhe5@huawei.com \
--to=liusizhe5@huawei$(echo .)com \
--cc=acme@kernel$(echo .)org \
--cc=adrian.hunter@intel$(echo .)com \
--cc=alexander.shishkin@linux$(echo .)intel.com \
--cc=bhelgaas@google$(echo .)com \
--cc=corbet@lwn$(echo .)net \
--cc=fanghao11@huawei$(echo .)com \
--cc=gaozhihao6@h-partners$(echo .)com \
--cc=irogers@google$(echo .)com \
--cc=james.clark@linaro$(echo .)org \
--cc=jic23@kernel$(echo .)org \
--cc=john.g.garry@oracle$(echo .)com \
--cc=jolsa@kernel$(echo .)org \
--cc=leo.yan@linux$(echo .)dev \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-doc@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-pci@vger$(echo .)kernel.org \
--cc=linux-perf-users@vger$(echo .)kernel.org \
--cc=linuxarm@huawei$(echo .)com \
--cc=liyihang9@h-partners$(echo .)com \
--cc=mark.rutland@arm$(echo .)com \
--cc=mathieu.desnoyers@efficios$(echo .)com \
--cc=mhiramat@kernel$(echo .)org \
--cc=mike.leach@arm$(echo .)com \
--cc=mingo@redhat$(echo .)com \
--cc=namhyung@kernel$(echo .)org \
--cc=peterz@infradead$(echo .)org \
--cc=prime.zeng@hisilicon$(echo .)com \
--cc=rostedt@goodmis$(echo .)org \
--cc=shenyang39@huawei$(echo .)com \
--cc=skhan@linuxfoundation$(echo .)org \
--cc=wangyushan12@huawei$(echo .)com \
--cc=will@kernel$(echo .)org \
--cc=wuyifan50@huawei$(echo .)com \
--cc=yangyccccc@gmail$(echo .)com \
--cc=yuzhichengcheng@h-partners$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox