[PATCH v2 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing
From: Sizhe Liu
Date: Thu Aug 27 2026 - 10:09:38 EST
Merge the printing of HEAD0 for both 4DW and 8DW TLP headers into
hisi_ptt_print_head0(). This unifies the entry point and makes it
easier to add HEAD1/HEAD2/HEAD3 field parsing in subsequent patches.
Signed-off-by: Sizhe Liu <liusizhe5@xxxxxxxxxx>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 56 +++++++++++--------
1 file changed, 33 insertions(+), 23 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 23ae99f33c9f..00bd9309df68 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
@@ -108,6 +108,33 @@ static void hisi_ptt_print_pkt(struct hisi_ptt_pkt_buf *pkt_buf,
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
+static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *color = PERF_COLOR_BLUE;
+ uint32_t dw;
+
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw);
+
+ if (pkt_buf->pkt_type == HISI_PTT_4DW_PKT)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Format",
+ FIELD_GET(HISI_PTT_HEAD0_4DW_FORMAT, dw),
+ "Type", FIELD_GET(HISI_PTT_HEAD0_4DW_TYPE, dw),
+ "T9", FIELD_GET(HISI_PTT_HEAD0_4DW_T9, dw),
+ "T8", FIELD_GET(HISI_PTT_HEAD0_4DW_T8, dw),
+ "TH", FIELD_GET(HISI_PTT_HEAD0_4DW_TH, dw),
+ "SO", FIELD_GET(HISI_PTT_HEAD0_4DW_SO, dw),
+ "Length", FIELD_GET(HISI_PTT_HEAD0_4DW_LEN, dw),
+ "Time", FIELD_GET(HISI_PTT_HEAD0_4DW_TIME, dw));
+ else
+ color_fprintf(stdout, color, " %s\n",
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0]);
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
@@ -119,39 +146,22 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
continue;
}
+ if (i == HISI_PTT_8DW_HEAD0) {
+ hisi_ptt_print_head0(pkt_buf);
+ continue;
+ }
+
hisi_ptt_print_pkt(pkt_buf, hisi_ptt_8dw_pkt_field_name[i]);
}
return hisi_ptt_pkt_size[HISI_PTT_8DW_PKT];
}
-static void hisi_ptt_4dw_print_dw0(struct hisi_ptt_pkt_buf *pkt_buf)
-{
- const char *color = PERF_COLOR_BLUE;
- uint32_t dw;
-
- dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
- hisi_ptt_print_raw_record(pkt_buf->pos, dw);
-
- color_fprintf(stdout, color,
- " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
- "Format", FIELD_GET(HISI_PTT_HEAD0_4DW_FORMAT, dw),
- "Type", FIELD_GET(HISI_PTT_HEAD0_4DW_TYPE, dw),
- "T9", FIELD_GET(HISI_PTT_HEAD0_4DW_T9, dw),
- "T8", FIELD_GET(HISI_PTT_HEAD0_4DW_T8, dw),
- "TH", FIELD_GET(HISI_PTT_HEAD0_4DW_TH, dw),
- "SO", FIELD_GET(HISI_PTT_HEAD0_4DW_SO, dw),
- "Length", FIELD_GET(HISI_PTT_HEAD0_4DW_LEN, dw),
- "Time", FIELD_GET(HISI_PTT_HEAD0_4DW_TIME, dw));
-
- pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
-}
-
static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
- hisi_ptt_4dw_print_dw0(pkt_buf);
+ 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]);
--
2.33.0