* [PATCH v2 1/8] perf hisi-ptt: Abstract trace data buf and offset
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
Abstract the base address, current offset, length and packet type of
analysing trace data into structure hisi_ptt_pkt_buf and move the step
of current offset into the corresponding functions.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 42 +++++++++----------
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 9 +++-
tools/perf/util/hisi-ptt.c | 20 ++++-----
3 files changed, 37 insertions(+), 34 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 72a877fd7236..ef72223d3854 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
@@ -75,16 +75,17 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = {
[HISI_PTT_4DW_HEAD3] = "Header DW3",
};
-static void hisi_ptt_print_pkt(const unsigned char *buf, int pos, const char *desc)
+static void hisi_ptt_print_pkt(struct hisi_ptt_pkt_buf *pkt_buf,
+ const char *desc)
{
const char *color = PERF_COLOR_BLUE;
uint8_t byte;
uint32_t dw;
int i;
- dw = get_unaligned_le32(buf + pos);
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
printf(".");
- color_fprintf(stdout, color, " %08x: ", pos);
+ color_fprintf(stdout, color, " %08zx: ", pkt_buf->pos);
for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++) {
byte = (dw >> (24 - i * 8)) & 0xFF;
color_fprintf(stdout, color, "%02x ", byte);
@@ -92,36 +93,36 @@ static void hisi_ptt_print_pkt(const unsigned char *buf, int pos, const char *de
for (i = 0; i < HISI_PTT_MAX_SPACE_LEN; i++)
color_fprintf(stdout, color, " ");
color_fprintf(stdout, color, " %s\n", desc);
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
-static int hisi_ptt_8dw_pkt_desc(const unsigned char *buf, int pos)
+static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
for (i = 0; i < HISI_PTT_8DW_TYPE_MAX; i++) {
/* Do not show 8DW check field and reserved fields */
if (i == HISI_PTT_8DW_CHK_AND_RSV0 || i == HISI_PTT_8DW_RSV1) {
- pos += HISI_PTT_FIELD_LENGTH;
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
continue;
}
- hisi_ptt_print_pkt(buf, pos, hisi_ptt_8dw_pkt_field_name[i]);
- pos += HISI_PTT_FIELD_LENGTH;
+ 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(const unsigned char *buf, int pos)
+static void hisi_ptt_4dw_print_dw0(struct hisi_ptt_pkt_buf *pkt_buf)
{
const char *color = PERF_COLOR_BLUE;
uint8_t byte;
uint32_t dw;
int i;
- dw = get_unaligned_le32(buf + pos);
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
printf(".");
- color_fprintf(stdout, color, " %08x: ", pos);
+ color_fprintf(stdout, color, " %08zx: ", pkt_buf->pos);
for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++) {
byte = (dw >> (24 - i * 8)) & 0xFF;
color_fprintf(stdout, color, "%02x ", byte);
@@ -139,27 +140,26 @@ static void hisi_ptt_4dw_print_dw0(const unsigned char *buf, int pos)
"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(const unsigned char *buf, int pos)
+static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
- hisi_ptt_4dw_print_dw0(buf, pos);
- pos += HISI_PTT_FIELD_LENGTH;
+ hisi_ptt_4dw_print_dw0(pkt_buf);
- for (i = 0; i < HISI_PTT_4DW_TYPE_MAX; i++) {
- hisi_ptt_print_pkt(buf, pos, hisi_ptt_4dw_pkt_field_name[i]);
- pos += HISI_PTT_FIELD_LENGTH;
- }
+ for (i = 0; i < HISI_PTT_4DW_TYPE_MAX; i++)
+ hisi_ptt_print_pkt(pkt_buf, hisi_ptt_4dw_pkt_field_name[i]);
return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT];
}
-int hisi_ptt_pkt_desc(const unsigned char *buf, int pos, enum hisi_ptt_pkt_type type)
+int hisi_ptt_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
- if (type == HISI_PTT_8DW_PKT)
- return hisi_ptt_8dw_pkt_desc(buf, pos);
+ if (pkt_buf->pkt_type == HISI_PTT_8DW_PKT)
+ return hisi_ptt_8dw_pkt_desc(pkt_buf);
- return hisi_ptt_4dw_pkt_desc(buf, pos);
+ return hisi_ptt_4dw_pkt_desc(pkt_buf);
}
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
index 3b349fcc24ae..6747878b030e 100644
--- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
+++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
@@ -38,6 +38,13 @@ static int hisi_ptt_pkt_size[] = {
[HISI_PTT_8DW_PKT] = 32,
};
-int hisi_ptt_pkt_desc(const unsigned char *buf, int pos, enum hisi_ptt_pkt_type type);
+struct hisi_ptt_pkt_buf {
+ const unsigned char *buf;
+ size_t pos;
+ size_t len;
+ enum hisi_ptt_pkt_type pkt_type;
+};
+
+int hisi_ptt_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf);
#endif
diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c
index e73c57f9e8a4..ea659947c27f 100644
--- a/tools/perf/util/hisi-ptt.c
+++ b/tools/perf/util/hisi-ptt.c
@@ -57,22 +57,18 @@ static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_unused,
unsigned char *buf, size_t len)
{
const char *color = PERF_COLOR_BLUE;
- enum hisi_ptt_pkt_type type;
- size_t pos = 0;
- int pkt_len;
+ struct hisi_ptt_pkt_buf pkt_buf;
- type = hisi_ptt_check_packet_type(buf, len);
- len = round_down(len, hisi_ptt_pkt_size[type]);
+ pkt_buf.buf = buf;
+ pkt_buf.pos = 0;
+ pkt_buf.pkt_type = hisi_ptt_check_packet_type(buf, len);
+ pkt_buf.len = round_down(len, hisi_ptt_pkt_size[pkt_buf.pkt_type]);
color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n",
- len);
+ pkt_buf.len);
- while (len > 0) {
- pkt_len = hisi_ptt_pkt_desc(buf, pos, type);
- if (!pkt_len)
+ while (pkt_buf.pos < pkt_buf.len) {
+ if (!hisi_ptt_pkt_desc(&pkt_buf))
color_fprintf(stdout, color, " Bad packet!\n");
-
- pos += pkt_len;
- len -= pkt_len;
}
}
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 1/8] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 3/8] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
Add the missing HISI_PTT_4DW_HEAD0 entry to the 4DW field name table
and add the HISI_PTT_8DW_CHK_AND_RSV0/HISI_PTT_8DW_RSV1 entries to
the 8DW field name table so that all DW indices have corresponding
names.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 20 +++++++++++--------
1 file changed, 12 insertions(+), 8 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 ef72223d3854..766665414ad8 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
@@ -54,6 +54,7 @@ enum hisi_ptt_8dw_pkt_field_type {
};
enum hisi_ptt_4dw_pkt_field_type {
+ HISI_PTT_4DW_HEAD0,
HISI_PTT_4DW_HEAD1,
HISI_PTT_4DW_HEAD2,
HISI_PTT_4DW_HEAD3,
@@ -61,15 +62,18 @@ enum hisi_ptt_4dw_pkt_field_type {
};
static const char * const hisi_ptt_8dw_pkt_field_name[] = {
- [HISI_PTT_8DW_PREFIX] = "Prefix",
- [HISI_PTT_8DW_HEAD0] = "Header DW0",
- [HISI_PTT_8DW_HEAD1] = "Header DW1",
- [HISI_PTT_8DW_HEAD2] = "Header DW2",
- [HISI_PTT_8DW_HEAD3] = "Header DW3",
- [HISI_PTT_8DW_TIME] = "Time"
+ [HISI_PTT_8DW_CHK_AND_RSV0] = "CHK & RSV0",
+ [HISI_PTT_8DW_PREFIX] = "Prefix",
+ [HISI_PTT_8DW_HEAD0] = "Header DW0",
+ [HISI_PTT_8DW_HEAD1] = "Header DW1",
+ [HISI_PTT_8DW_HEAD2] = "Header DW2",
+ [HISI_PTT_8DW_HEAD3] = "Header DW3",
+ [HISI_PTT_8DW_RSV1] = "RSV1",
+ [HISI_PTT_8DW_TIME] = "Time"
};
static const char * const hisi_ptt_4dw_pkt_field_name[] = {
+ [HISI_PTT_4DW_HEAD0] = "Header DW0",
[HISI_PTT_4DW_HEAD1] = "Header DW1",
[HISI_PTT_4DW_HEAD2] = "Header DW2",
[HISI_PTT_4DW_HEAD3] = "Header DW3",
@@ -100,7 +104,7 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
- for (i = 0; i < HISI_PTT_8DW_TYPE_MAX; i++) {
+ for (i = HISI_PTT_8DW_CHK_AND_RSV0; i < HISI_PTT_8DW_TYPE_MAX; i++) {
/* Do not show 8DW check field and reserved fields */
if (i == HISI_PTT_8DW_CHK_AND_RSV0 || i == HISI_PTT_8DW_RSV1) {
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
@@ -150,7 +154,7 @@ static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
hisi_ptt_4dw_print_dw0(pkt_buf);
- for (i = 0; i < HISI_PTT_4DW_TYPE_MAX; i++)
+ 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]);
return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT];
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 3/8] perf hisi-ptt: Extract the raw data printing part
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 1/8] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
Extract the raw data printing part of the TLP header into
hisi_ptt_print_raw_record() for reuse by subsequent patches that
add field-level parsing of individual DW headers.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 31 +++++++++----------
1 file changed, 15 insertions(+), 16 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 766665414ad8..23ae99f33c9f 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
@@ -79,23 +79,31 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = {
[HISI_PTT_4DW_HEAD3] = "Header DW3",
};
-static void hisi_ptt_print_pkt(struct hisi_ptt_pkt_buf *pkt_buf,
- const char *desc)
+static void hisi_ptt_print_raw_record(size_t offset, uint32_t value)
{
const char *color = PERF_COLOR_BLUE;
uint8_t byte;
- uint32_t dw;
int i;
- dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
printf(".");
- color_fprintf(stdout, color, " %08zx: ", pkt_buf->pos);
+ color_fprintf(stdout, color, " %08zx: ", offset);
for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++) {
- byte = (dw >> (24 - i * 8)) & 0xFF;
+ byte = (value >> (24 - i * 8)) & 0xFF;
color_fprintf(stdout, color, "%02x ", byte);
}
for (i = 0; i < HISI_PTT_MAX_SPACE_LEN; i++)
color_fprintf(stdout, color, " ");
+}
+
+static void hisi_ptt_print_pkt(struct hisi_ptt_pkt_buf *pkt_buf,
+ const char *desc)
+{
+ const char *color = PERF_COLOR_BLUE;
+ uint32_t value;
+
+ value = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, value);
+
color_fprintf(stdout, color, " %s\n", desc);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
@@ -120,19 +128,10 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
static void hisi_ptt_4dw_print_dw0(struct hisi_ptt_pkt_buf *pkt_buf)
{
const char *color = PERF_COLOR_BLUE;
- uint8_t byte;
uint32_t dw;
- int i;
dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
- printf(".");
- color_fprintf(stdout, color, " %08zx: ", pkt_buf->pos);
- for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++) {
- byte = (dw >> (24 - i * 8)) & 0xFF;
- color_fprintf(stdout, color, "%02x ", byte);
- }
- for (i = 0; i < HISI_PTT_MAX_SPACE_LEN; i++)
- color_fprintf(stdout, color, " ");
+ 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",
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (2 preceding siblings ...)
2026-08-27 14:04 ` [PATCH v2 3/8] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 5/8] perf hisi-ptt: Add parsing of supported message types Sizhe Liu
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
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@huawei.com>
---
.../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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 5/8] perf hisi-ptt: Add parsing of supported message types
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (3 preceding siblings ...)
2026-08-27 14:04 ` [PATCH v2 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 6/8] perf hisi-ptt: Add field-level parsing for header DW2/DW3 Sizhe Liu
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
Classify TLP messages by Header DW0 Format field and Type field for
both 4DW and 8DW formats, according to PCIe r6.4 sec 2.2.1.1 & 2.2.1.2.
Parsing packets into:
- MWr (Posted Memory Write request)
- Msg (Posted Message request)
- Atom (Non-Posted Atomic request)
- IO (Non-Posted IO request)
- CFG (Non-Posted Configuration request)
- CPL (Completion request)
The parsed message type is stored in pkt_buf->pkt_msg_type and will
be used by subsequent patches to select the correct field layout for
DW2 and DW3 printing.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 62 +++++++++++++++++++
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 16 +++++
tools/perf/util/hisi-ptt.c | 1 +
3 files changed, 79 insertions(+)
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 00bd9309df68..e63fe1534693 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
@@ -79,6 +79,66 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = {
[HISI_PTT_4DW_HEAD3] = "Header DW3",
};
+/* TLP message parsers below according to PCIe r6.4 sec 2.2.1.1 & 2.2.1.2 */
+static bool hisi_ptt_is_mwr_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0x2 || format == 0x3) && (type == 0);
+}
+
+static bool hisi_ptt_is_msg_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0x1 || format == 0x3) && ((type & 0x18) == 0x10);
+}
+
+static bool hisi_ptt_is_io_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0 || format == 0x2) && (type == 0x2);
+}
+
+static bool hisi_ptt_is_atomic_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0x2 || format == 0x3) &&
+ (type == 0xc || type == 0xd || type == 0xe);
+}
+
+static bool hisi_ptt_is_cfg_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0 || format == 0x2) && (type == 0x4 || type == 0x5);
+}
+
+static bool hisi_ptt_is_cpl_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0 || format == 0x2) && (type == 0xa || type == 0xb);
+}
+
+static int hisi_ptt_parse_pkt_msg_type(uint32_t dw,
+ enum hisi_ptt_pkt_type pkt_type)
+{
+ uint32_t format, type;
+
+ format = (pkt_type == HISI_PTT_4DW_PKT) ?
+ FIELD_GET(HISI_PTT_HEAD0_4DW_FORMAT, dw) :
+ FIELD_GET(HISI_PTT_HEAD0_8DW_FORMAT, dw);
+ type = (pkt_type == HISI_PTT_4DW_PKT) ?
+ FIELD_GET(HISI_PTT_HEAD0_4DW_TYPE, dw) :
+ FIELD_GET(HISI_PTT_HEAD0_8DW_TYPE, dw);
+
+ if (hisi_ptt_is_mwr_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_MWR;
+ else if (hisi_ptt_is_msg_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_MSG;
+ else if (hisi_ptt_is_atomic_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_ATOM;
+ else if (hisi_ptt_is_io_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_IO;
+ else if (hisi_ptt_is_cfg_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_CFG;
+ else if (hisi_ptt_is_cpl_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_CPL;
+
+ return HISI_PTT_PKT_TYPE_UNKNOWN;
+}
+
static void hisi_ptt_print_raw_record(size_t offset, uint32_t value)
{
const char *color = PERF_COLOR_BLUE;
@@ -114,6 +174,8 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
uint32_t dw;
dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ pkt_buf->pkt_msg_type = hisi_ptt_parse_pkt_msg_type(dw,
+ pkt_buf->pkt_type);
hisi_ptt_print_raw_record(pkt_buf->pos, dw);
if (pkt_buf->pkt_type == HISI_PTT_4DW_PKT)
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
index 6747878b030e..9d98362d76b1 100644
--- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
+++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
@@ -27,6 +27,10 @@
#define HISI_PTT_HEAD0_4DW_TYPE GENMASK_U32(29, 25)
#define HISI_PTT_HEAD0_4DW_FORMAT GENMASK_U32(31, 30)
+/* Header DW0 fields for 8DW format */
+#define HISI_PTT_HEAD0_8DW_TYPE GENMASK_U32(28, 24)
+#define HISI_PTT_HEAD0_8DW_FORMAT GENMASK_U32(31, 29)
+
enum hisi_ptt_pkt_type {
HISI_PTT_4DW_PKT,
HISI_PTT_8DW_PKT,
@@ -38,11 +42,23 @@ static int hisi_ptt_pkt_size[] = {
[HISI_PTT_8DW_PKT] = 32,
};
+enum hisi_ptt_pkt_msg_type {
+ HISI_PTT_PKT_TYPE_UNKNOWN, /* Types do not support analysis */
+ HISI_PTT_PKT_TYPE_MWR, /* P-(MemWr) */
+ HISI_PTT_PKT_TYPE_MSG, /* P-(Message) */
+ HISI_PTT_PKT_TYPE_ATOM, /* NP-(Atomic) */
+ HISI_PTT_PKT_TYPE_IO, /* NP-(IO) */
+ HISI_PTT_PKT_TYPE_CFG, /* NP-(CFG) */
+ HISI_PTT_PKT_TYPE_CPL, /* CPL-(CPL) */
+ HISI_PTT_PKT_TYPE_MAX
+};
+
struct hisi_ptt_pkt_buf {
const unsigned char *buf;
size_t pos;
size_t len;
enum hisi_ptt_pkt_type pkt_type;
+ enum hisi_ptt_pkt_msg_type pkt_msg_type;
};
int hisi_ptt_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf);
diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c
index ea659947c27f..78817ae7a8ea 100644
--- a/tools/perf/util/hisi-ptt.c
+++ b/tools/perf/util/hisi-ptt.c
@@ -63,6 +63,7 @@ static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_unused,
pkt_buf.pos = 0;
pkt_buf.pkt_type = hisi_ptt_check_packet_type(buf, len);
pkt_buf.len = round_down(len, hisi_ptt_pkt_size[pkt_buf.pkt_type]);
+ pkt_buf.pkt_msg_type = HISI_PTT_PKT_TYPE_UNKNOWN;
color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n",
pkt_buf.len);
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 6/8] perf hisi-ptt: Add field-level parsing for header DW2/DW3
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (4 preceding siblings ...)
2026-08-27 14:04 ` [PATCH v2 5/8] perf hisi-ptt: Add parsing of supported message types Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Sizhe Liu
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
Add field-level parsing of Header DW2 and DW3 of the TLP, separating
the layout for CFG TLPs and CPL TLPs. The message type parsed in the
previous patch is used to select the correct field layout.
DW2 fields are common to MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr
TLPs, parsed with FIELD_GET() against HISI_PTT_HEAD2_* masks.
DW3 fields have two layouts:
- CfgRd0/CfgWr0/CfgRd1/CfgWr1 use HISI_PTT_HEAD3_CFG_* masks
- Cpl/CplD/CplLk/CplDlk use HISI_PTT_HEAD3_CPL_* masks
HiSilicon PCIe trace device hardware is responsible for packet collection,
parsing, extraction and fills the corresponding fields with the required
positions. The packet decoder software will perform the parsing and
printing of fields filled by hardware.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 111 ++++++++++++++++--
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 39 ++++++
2 files changed, 141 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 e63fe1534693..de1d4071e209 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
@@ -197,6 +197,89 @@ 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)
+{
+ /* Currently, no distinction here for 4DW foramt and 8DW format */
+ hisi_ptt_print_pkt(pkt_buf,
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD1]);
+}
+
+static void hisi_ptt_print_head2(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_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",
+ FIELD_GET(HISI_PTT_HEAD2_RESERVED, dw),
+ "Request Segment",
+ FIELD_GET(HISI_PTT_HEAD2_REQ_SEG, dw),
+ "RSV", FIELD_GET(HISI_PTT_HEAD2_RSV, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD2_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD2_T, dw),
+ "Tag", FIELD_GET(HISI_PTT_HEAD2_TAG, dw),
+ "Header DW2",
+ FIELD_GET(HISI_PTT_HEAD2_HEADER_DW2, dw));
+ 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;
+ 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_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",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_DST_SEG, dw),
+ "Completer Segment",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_CPL_SEG, dw),
+ "DSV", FIELD_GET(HISI_PTT_HEAD3_CPL_DSV, dw),
+ "Reserved",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_RESERVED, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_CPL_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_CPL_T, dw),
+ "Tag", FIELD_GET(HISI_PTT_HEAD3_CPL_TAG, dw));
+ 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",
+ FIELD_GET(HISI_PTT_HEAD3_CFG_RESERVED, dw),
+ "Destination Segment",
+ FIELD_GET(HISI_PTT_HEAD3_CFG_DST_SEG, dw),
+ "DSV", FIELD_GET(HISI_PTT_HEAD3_CFG_DSV, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_CFG_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_CFG_T, dw),
+ "Tag", FIELD_GET(HISI_PTT_HEAD3_CFG_TAG, dw),
+ "Header DW3",
+ FIELD_GET(HISI_PTT_HEAD3_CFG_HEADER_DW3, dw));
+ 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;
@@ -208,12 +291,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];
@@ -221,12 +316,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];
}
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
index 9d98362d76b1..9663615ea3b5 100644
--- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
+++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
@@ -31,6 +31,45 @@
#define HISI_PTT_HEAD0_8DW_TYPE GENMASK_U32(28, 24)
#define HISI_PTT_HEAD0_8DW_FORMAT GENMASK_U32(31, 29)
+/* Header DW2 fields for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr TLPs
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|----------------|----|---|--|-----------|----------|
+ * fields [Reserved][Request Segment][RSV][TV][T][Tag<13:10>][Header DW2]
+ */
+#define HISI_PTT_HEAD2_HEADER_DW2 GENMASK_U32(15, 0)
+#define HISI_PTT_HEAD2_TAG GENMASK_U32(19, 16)
+#define HISI_PTT_HEAD2_T BIT_U32(20)
+#define HISI_PTT_HEAD2_TV BIT_U32(21)
+#define HISI_PTT_HEAD2_RSV BIT_U32(22)
+#define HISI_PTT_HEAD2_REQ_SEG GENMASK_U32(30, 23)
+#define HISI_PTT_HEAD2_RESERVED BIT_U32(31)
+
+/* Header DW3 fields for CfgRd0/CfgWr0/CfgRd1/CfgWr1 TLPs
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|--------------------|----|---|--|-----------|----------|
+ * fields [Reserved][Destination Segment][DSV][TV][T][Tag<13:10>][Header DW3]
+ */
+#define HISI_PTT_HEAD3_CFG_HEADER_DW3 GENMASK_U32(15, 0)
+#define HISI_PTT_HEAD3_CFG_TAG GENMASK_U32(19, 16)
+#define HISI_PTT_HEAD3_CFG_T BIT_U32(20)
+#define HISI_PTT_HEAD3_CFG_TV BIT_U32(21)
+#define HISI_PTT_HEAD3_CFG_DSV BIT_U32(22)
+#define HISI_PTT_HEAD3_CFG_DST_SEG GENMASK_U32(30, 23)
+#define HISI_PTT_HEAD3_CFG_RESERVED BIT_U32(31)
+
+/* Header DW3 fields for Cpl/CplD/CplLk/CplDlk TLPs
+ * bits [ 31:24 ][ 23:16 ][15][ 14:6 ][5][4][ 3:0 ]
+ * |--------------------|------------------|----|---------|--|---|----------|
+ * fields [Destination Segment][Completer Segment][DSV][Reserved][TV][T][Tag<13:10>]
+ */
+#define HISI_PTT_HEAD3_CPL_TAG GENMASK_U32(3, 0)
+#define HISI_PTT_HEAD3_CPL_T BIT_U32(4)
+#define HISI_PTT_HEAD3_CPL_TV BIT_U32(5)
+#define HISI_PTT_HEAD3_CPL_RESERVED GENMASK_U32(14, 6)
+#define HISI_PTT_HEAD3_CPL_DSV BIT_U32(15)
+#define HISI_PTT_HEAD3_CPL_CPL_SEG GENMASK_U32(23, 16)
+#define HISI_PTT_HEAD3_CPL_DST_SEG GENMASK_U32(31, 24)
+
enum hisi_ptt_pkt_type {
HISI_PTT_4DW_PKT,
HISI_PTT_8DW_PKT,
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (5 preceding siblings ...)
2026-08-27 14:04 ` [PATCH v2 6/8] perf hisi-ptt: Add field-level parsing for header DW2/DW3 Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
2026-08-27 14:04 ` [PATCH v2 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Sizhe Liu
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
Introduce a `pattern` PMU config field (config:36-39) that controls
which TLP header format the hardware traces. bit[3:1] are reserved for
future extension and only bit0 is used currently:
- pattern=0 (default, compatibility mode): the driver sets bit[8] of
HISI_PTT_TRACE_CTRL so the hardware traces the data in compatibility
mode.
- pattern=1: the driver clears bit[8] of HISI_PTT_TRACE_CTRL so the
hardware traces the data pattern including some bitfields of the TLP
header defined in PCIe r6.4 sec 2.2.1.2.
Note that bit[8] of HISI_PTT_TRACE_CTRL is inverted with respect to the
`pattern` value: bit[8]=1 selects the legacy format, bit[8]=0 selects
the new format. Bit[11:9] is still reserved, which is consistent with the
PMU config field. The driver validates the 4-bit value in
hisi_ptt_trace_valid_pattern() and applies it in hisi_ptt_trace_start().
Document the new parameter in Documentation/trace/hisi-ptt.rst.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
Documentation/trace/hisi-ptt.rst | 25 +++++++++++++++++++++++--
drivers/hwtracing/ptt/hisi_ptt.c | 25 ++++++++++++++++++++++++-
drivers/hwtracing/ptt/hisi_ptt.h | 4 ++++
3 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/Documentation/trace/hisi-ptt.rst b/Documentation/trace/hisi-ptt.rst
index f6a2655f99e5..c95eaa12f4d3 100644
--- a/Documentation/trace/hisi-ptt.rst
+++ b/Documentation/trace/hisi-ptt.rst
@@ -255,7 +255,28 @@ directly from the TLP header.
DW2 [ Header DW2 ]
DW3 [ Header DW3 ]
-5. Memory Management
+5. Trace pattern
+-----------------
+
+You can control whether the trace is taken with the new version of the
+TLP header format by specifying the `pattern` parameter. The default
+value is 0, which means the legacy format is used for backward
+compatibility. The parameter value is 4 bit and bit[3:1] are currently
+reserved for extension. Current supported values are shown below:
+
+- 4'b0000: legacy trace format
+ DW2 and DW3 are printed with generic field names only, and
+ no message-type-basedfield decoding.
+- 4'b0001: trace format v1
+ DW2 and DW3 are decoded according to the TLP message type (MWr,
+ Msg, Atomic, IO, CPL, Cfg) with detailed field names. It is recommended to
+ use trace format v1 when the current PCIe link generation is higher than
+ PCIe 6.0.
+
+For trace data recorded by an older tracer without the `pattern` parameter,
+the decoder will work as `pattern` forced to 0.
+
+6. Memory Management
--------------------
The traced TLP headers will be written to the memory allocated
@@ -274,7 +295,7 @@ will commit the AUX buffer first and then apply for a new one with
the same size. The size of AUX buffer is default to 16MiB. User can
adjust the size by specifying the `-m` parameter of the perf command.
-6. Decoding
+7. Decoding
-----------
You can decode the traced data with `perf report -D` command (currently
diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
index 94c371c49135..1696c30ac4c9 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -233,6 +233,10 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
val |= FIELD_PREP(HISI_PTT_TRACE_CTRL_TARGET_SEL, hisi_ptt->trace_ctrl.filter);
if (!hisi_ptt->trace_ctrl.is_port)
val |= HISI_PTT_TRACE_CTRL_FILTER_MODE;
+ if (!ctrl->pattern)
+ val |= HISI_PTT_TRACE_CTRL_PATTERN;
+ else
+ val &= ~HISI_PTT_TRACE_CTRL_PATTERN;
/* Start the Trace */
val |= HISI_PTT_TRACE_CTRL_EN;
@@ -805,12 +809,14 @@ PMU_FORMAT_ATTR(filter, "config:0-19");
PMU_FORMAT_ATTR(direction, "config:20-23");
PMU_FORMAT_ATTR(type, "config:24-31");
PMU_FORMAT_ATTR(format, "config:32-35");
+PMU_FORMAT_ATTR(pattern, "config:36-39");
static struct attribute *hisi_ptt_pmu_format_attrs[] = {
&format_attr_filter.attr,
&format_attr_direction.attr,
&format_attr_type.attr,
&format_attr_format.attr,
+ &format_attr_pattern.attr,
NULL
};
@@ -940,6 +946,15 @@ static int hisi_ptt_trace_valid_format(u32 val)
return -EINVAL;
}
+static int hisi_ptt_trace_valid_pattern(u32 val)
+{
+ /* Currently only bit0 is used, bit[3:1] are reserved for extension. */
+ if (val <= 1)
+ return 0;
+
+ return -EINVAL;
+}
+
static int hisi_ptt_trace_valid_filter(struct hisi_ptt *hisi_ptt, u64 config)
{
unsigned long val, port_mask = hisi_ptt->port_mask;
@@ -990,6 +1005,9 @@ static void hisi_ptt_pmu_init_configs(struct hisi_ptt *hisi_ptt, struct perf_eve
val = FIELD_GET(HISI_PTT_PMU_FORMAT_MASK, event->attr.config);
ctrl->format = val;
+
+ val = FIELD_GET(HISI_PTT_PMU_PATTERN_MASK, event->attr.config);
+ ctrl->pattern = val;
}
static int hisi_ptt_pmu_event_init(struct perf_event *event)
@@ -1024,7 +1042,12 @@ static int hisi_ptt_pmu_event_init(struct perf_event *event)
return ret;
val = FIELD_GET(HISI_PTT_PMU_FORMAT_MASK, event->attr.config);
- return hisi_ptt_trace_valid_format(val);
+ ret = hisi_ptt_trace_valid_format(val);
+ if (ret < 0)
+ return ret;
+
+ val = FIELD_GET(HISI_PTT_PMU_PATTERN_MASK, event->attr.config);
+ return hisi_ptt_trace_valid_pattern(val);
}
static void *hisi_ptt_pmu_setup_aux(struct perf_event *event, void **pages,
diff --git a/drivers/hwtracing/ptt/hisi_ptt.h b/drivers/hwtracing/ptt/hisi_ptt.h
index 46030aa88081..584f65ba1e32 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.h
+++ b/drivers/hwtracing/ptt/hisi_ptt.h
@@ -41,6 +41,7 @@
#define HISI_PTT_TRACE_CTRL_RST BIT(1)
#define HISI_PTT_TRACE_CTRL_RXTX_SEL GENMASK(3, 2)
#define HISI_PTT_TRACE_CTRL_TYPE_SEL GENMASK(7, 4)
+#define HISI_PTT_TRACE_CTRL_PATTERN BIT(8)
#define HISI_PTT_TRACE_CTRL_DATA_FORMAT BIT(14)
#define HISI_PTT_TRACE_CTRL_FILTER_MODE BIT(15)
#define HISI_PTT_TRACE_CTRL_TARGET_SEL GENMASK(31, 16)
@@ -89,6 +90,7 @@
#define HISI_PTT_PMU_DIRECTION_MASK GENMASK(23, 20)
#define HISI_PTT_PMU_TYPE_MASK GENMASK(31, 24)
#define HISI_PTT_PMU_FORMAT_MASK GENMASK(35, 32)
+#define HISI_PTT_PMU_PATTERN_MASK GENMASK(39, 36)
/**
* struct hisi_ptt_tune_desc - Describe tune event for PTT tune
@@ -127,6 +129,7 @@ struct hisi_ptt_dma_buffer {
* @filter: filter value for tracing the TLP headers
* @format: format of the TLP headers to trace
* @type: type of the TLP headers to trace
+ * @pattern: pattern of the TLP headers to trace
*/
struct hisi_ptt_trace_ctrl {
struct hisi_ptt_dma_buffer *trace_buf;
@@ -139,6 +142,7 @@ struct hisi_ptt_trace_ctrl {
u32 filter:16;
u32 format:1;
u32 type:4;
+ u32 pattern:1;
};
/*
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility
2026-08-27 14:04 [PATCH v2 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (6 preceding siblings ...)
2026-08-27 14:04 ` [PATCH v2 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Sizhe Liu
@ 2026-08-27 14:04 ` Sizhe Liu
7 siblings, 0 replies; 9+ messages in thread
From: Sizhe Liu @ 2026-08-27 14:04 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1
Cc: linux-kernel, linux-pci, linux-perf-users, linux-arm-kernel,
linux-doc, linuxarm, prime.zeng, liusizhe5
On the recording side, walk the evlist in hisi_ptt_info_fill() to find
the hisi_ptt event, read out the pattern bits from its config, and
forward the pattern version to the decoder through
auxtrace_info->priv[1] as HISI_PTT_PATTERN_LEGACY or HISI_PTT_PATTERN_V1.
On the decoding side, store the pattern version in struct hisi_ptt and
propagate it to struct hisi_ptt_pkt_buf. The printers of Header DW2
and DW3 check the version: HISI_PTT_PATTERN_V1 keeps the field-level
parsing introduced by the previous patches, while HISI_PTT_PATTERN_LEGACY
falls back to printing only the raw "Header DW2/DW3" label so legacy
traces remain decodable with the new tool.
The auxtrace priv size grows from one u64 to two. Use
HISI_PTT_AUXTRACE_PRIV_SIZE_LEGACY for the minimum header size check
and detect the actual priv_size at runtime to pick the pattern version.
For trace data recorded by an older tracer that does not support the
`pattern` parameter (no priv[1] in the header), the decoder defaults
to legacy mode (HISI_PTT_PATTERN_LEGACY) so the new tool keeps parsing
old traces correctly.
The hisi_ptt_pkt_size array is moved out of the shared header into
static definitions in the two .c files that consume it to avoid
multiple definitions.
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
tools/perf/arch/arm64/util/hisi-ptt.c | 18 +++++++++
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 39 ++++++++++++-------
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 8 ++--
tools/perf/util/hisi-ptt.c | 28 +++++++++----
tools/perf/util/hisi-ptt.h | 9 ++++-
5 files changed, 72 insertions(+), 30 deletions(-)
diff --git a/tools/perf/arch/arm64/util/hisi-ptt.c b/tools/perf/arch/arm64/util/hisi-ptt.c
index 52257715d2b7..ae8c16b5c324 100644
--- a/tools/perf/arch/arm64/util/hisi-ptt.c
+++ b/tools/perf/arch/arm64/util/hisi-ptt.c
@@ -6,6 +6,7 @@
#include <linux/kernel.h>
#include <linux/types.h>
+#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/zalloc.h>
@@ -20,6 +21,7 @@
#include "../../../util/evlist.h"
#include "../../../util/evsel.h"
#include "../../../util/hisi-ptt.h"
+#include "../../../util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h"
#include "../../../util/pmu.h"
#include "../../../util/record.h"
#include "../../../util/session.h"
@@ -49,6 +51,8 @@ static int hisi_ptt_info_fill(struct auxtrace_record *itr,
struct hisi_ptt_recording *pttr =
container_of(itr, struct hisi_ptt_recording, itr);
struct perf_pmu *hisi_ptt_pmu = pttr->hisi_ptt_pmu;
+ struct evsel *evsel;
+ u32 pattern = 0;
if (priv_size != HISI_PTT_AUXTRACE_PRIV_SIZE)
return -EINVAL;
@@ -56,8 +60,22 @@ static int hisi_ptt_info_fill(struct auxtrace_record *itr,
if (!evlist__core(session->evlist)->nr_mmaps)
return -EINVAL;
+ /*
+ * Walk the evlist to find the hisi_ptt event and read out the pattern
+ * bits from its config, which decides the decoder version used to
+ * parse the trace data.
+ */
+ evlist__for_each_entry(session->evlist, evsel) {
+ if (evsel->core.attr.type == hisi_ptt_pmu->type) {
+ pattern = FIELD_GET(HISI_PTT_PMU_PATTERN_MASK,
+ evsel->core.attr.config);
+ break;
+ }
+ }
+
auxtrace_info->type = PERF_AUXTRACE_HISI_PTT;
auxtrace_info->priv[0] = hisi_ptt_pmu->type;
+ auxtrace_info->priv[1] = pattern;
return 0;
}
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 de1d4071e209..63700380bf91 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
@@ -20,7 +20,7 @@
/*
* For 8DW format, the bit[31:11] of DW0 is always 0x1fffff, which can be
* used to distinguish the data format.
- * 8DW format is like:
+ * 8DW format legacy pattern is like:
* bits [ 31:11 ][ 10:0 ]
* |---------------------------------------|-------------------|
* DW0 [ 0x1fffff ][ Reserved (0x7ff) ]
@@ -32,7 +32,7 @@
* DW6 [ Reserved (0x0) ]
* DW7 [ Time ]
*
- * 4DW format is like:
+ * 4DW format legacy pattern is like:
* bits [31:30] [ 29:25 ][24][23][22][21][ 20:11 ][ 10:0 ]
* |-----|---------|---|---|---|---|-------------|-------------|
* DW0 [ Fmt ][ Type ][T9][T8][TH][SO][ Length ][ Time ]
@@ -79,6 +79,11 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = {
[HISI_PTT_4DW_HEAD3] = "Header DW3",
};
+static int hisi_ptt_pkt_size[] = {
+ [HISI_PTT_4DW_PKT] = 16,
+ [HISI_PTT_8DW_PKT] = 32,
+};
+
/* TLP message parsers below according to PCIe r6.4 sec 2.2.1.1 & 2.2.1.2 */
static bool hisi_ptt_is_mwr_tlp(uint32_t format, uint32_t type)
{
@@ -207,15 +212,20 @@ static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
{
const char *color = PERF_COLOR_BLUE;
+ const char *desc = 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];
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_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)
+ if (pkt_buf->pattern < HISI_PTT_PATTERN_V1)
+ color_fprintf(stdout, color, " %s\n", desc);
+ else 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",
@@ -229,10 +239,7 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
"Header DW2",
FIELD_GET(HISI_PTT_HEAD2_HEADER_DW2, dw));
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]);
+ color_fprintf(stdout, color, " %s\n", desc);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
@@ -240,12 +247,17 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
{
const char *color = PERF_COLOR_BLUE;
+ const char *desc = 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];
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_msg_type == HISI_PTT_PKT_TYPE_CPL)
+ if (pkt_buf->pattern < HISI_PTT_PATTERN_V1)
+ color_fprintf(stdout, color, " %s\n", desc);
+ else 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",
@@ -272,10 +284,7 @@ static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
"Header DW3",
FIELD_GET(HISI_PTT_HEAD3_CFG_HEADER_DW3, dw));
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]);
+ color_fprintf(stdout, color, " %s\n", desc);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
index 9663615ea3b5..5aaba79ef055 100644
--- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
+++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
@@ -16,6 +16,8 @@
#define HISI_PTT_IS_8DW_PKT GENMASK(31, 11)
#define HISI_PTT_MAX_SPACE_LEN 10
#define HISI_PTT_FIELD_LENGTH 4
+#define HISI_PTT_PATTERN_LEGACY 0
+#define HISI_PTT_PATTERN_V1 1
/* Header DW0 fields for 4DW format */
#define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0)
@@ -76,11 +78,6 @@ enum hisi_ptt_pkt_type {
HISI_PTT_PKT_MAX
};
-static int hisi_ptt_pkt_size[] = {
- [HISI_PTT_4DW_PKT] = 16,
- [HISI_PTT_8DW_PKT] = 32,
-};
-
enum hisi_ptt_pkt_msg_type {
HISI_PTT_PKT_TYPE_UNKNOWN, /* Types do not support analysis */
HISI_PTT_PKT_TYPE_MWR, /* P-(MemWr) */
@@ -98,6 +95,7 @@ struct hisi_ptt_pkt_buf {
size_t len;
enum hisi_ptt_pkt_type pkt_type;
enum hisi_ptt_pkt_msg_type pkt_msg_type;
+ size_t pattern;
};
int hisi_ptt_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf);
diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c
index 78817ae7a8ea..7cf778837337 100644
--- a/tools/perf/util/hisi-ptt.c
+++ b/tools/perf/util/hisi-ptt.c
@@ -35,6 +35,12 @@ struct hisi_ptt {
struct perf_session *session;
struct machine *machine;
u32 pmu_type;
+ u32 pattern;
+};
+
+static int hisi_ptt_pkt_size[] = {
+ [HISI_PTT_4DW_PKT] = 16,
+ [HISI_PTT_8DW_PKT] = 32,
};
static enum hisi_ptt_pkt_type hisi_ptt_check_packet_type(unsigned char *buf,
@@ -53,8 +59,7 @@ static enum hisi_ptt_pkt_type hisi_ptt_check_packet_type(unsigned char *buf,
return HISI_PTT_4DW_PKT;
}
-static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_unused,
- unsigned char *buf, size_t len)
+static void hisi_ptt_dump(struct hisi_ptt *ptt, unsigned char *buf, size_t len)
{
const char *color = PERF_COLOR_BLUE;
struct hisi_ptt_pkt_buf pkt_buf;
@@ -64,8 +69,9 @@ static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_unused,
pkt_buf.pkt_type = hisi_ptt_check_packet_type(buf, len);
pkt_buf.len = round_down(len, hisi_ptt_pkt_size[pkt_buf.pkt_type]);
pkt_buf.pkt_msg_type = HISI_PTT_PKT_TYPE_UNKNOWN;
- color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n",
- pkt_buf.len);
+ pkt_buf.pattern = (size_t)ptt->pattern;
+ color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes, pattern %zu\n",
+ pkt_buf.len, pkt_buf.pattern);
while (pkt_buf.pos < pkt_buf.len) {
if (!hisi_ptt_pkt_desc(&pkt_buf))
@@ -158,12 +164,13 @@ static bool hisi_ptt_evsel_is_auxtrace(struct perf_session *session,
return evsel->core.attr.type == ptt->pmu_type;
}
-static void hisi_ptt_print_info(__u64 type)
+static void hisi_ptt_print_info(u32 type, u32 pattern)
{
if (!dump_trace)
return;
- fprintf(stdout, " PMU Type %" PRId64 "\n", (s64) type);
+ fprintf(stdout, " PMU Type %" PRIu32 "\n", type);
+ fprintf(stdout, " Data Pattern %" PRIu32 "\n", pattern);
}
int hisi_ptt_process_auxtrace_info(union perf_event *event,
@@ -171,10 +178,13 @@ int hisi_ptt_process_auxtrace_info(union perf_event *event,
{
struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info;
struct hisi_ptt *ptt;
+ size_t priv_size;
- if (auxtrace_info->header.size < HISI_PTT_AUXTRACE_PRIV_SIZE +
+ if (auxtrace_info->header.size < HISI_PTT_AUXTRACE_PRIV_SIZE_LEGACY +
sizeof(struct perf_record_auxtrace_info))
return -EINVAL;
+ priv_size = auxtrace_info->header.size -
+ sizeof(struct perf_record_auxtrace_info);
ptt = zalloc(sizeof(*ptt));
if (!ptt)
@@ -184,6 +194,8 @@ int hisi_ptt_process_auxtrace_info(union perf_event *event,
ptt->machine = &session->machines.host; /* No kvm support */
ptt->auxtrace_type = auxtrace_info->type;
ptt->pmu_type = auxtrace_info->priv[0];
+ ptt->pattern = priv_size >= HISI_PTT_AUXTRACE_PRIV_SIZE_V1 ?
+ (u32)auxtrace_info->priv[1] : HISI_PTT_PATTERN_LEGACY;
ptt->auxtrace.process_event = hisi_ptt_process_event;
ptt->auxtrace.process_auxtrace_event = hisi_ptt_process_auxtrace_event;
@@ -193,7 +205,7 @@ int hisi_ptt_process_auxtrace_info(union perf_event *event,
ptt->auxtrace.evsel_is_auxtrace = hisi_ptt_evsel_is_auxtrace;
session->auxtrace = &ptt->auxtrace;
- hisi_ptt_print_info(auxtrace_info->priv[0]);
+ hisi_ptt_print_info(ptt->pmu_type, ptt->pattern);
return 0;
}
diff --git a/tools/perf/util/hisi-ptt.h b/tools/perf/util/hisi-ptt.h
index 2db9b4056214..912453b06e62 100644
--- a/tools/perf/util/hisi-ptt.h
+++ b/tools/perf/util/hisi-ptt.h
@@ -7,8 +7,13 @@
#ifndef INCLUDE__PERF_HISI_PTT_H__
#define INCLUDE__PERF_HISI_PTT_H__
-#define HISI_PTT_PMU_NAME "hisi_ptt"
-#define HISI_PTT_AUXTRACE_PRIV_SIZE sizeof(u64)
+#include <linux/bits.h>
+
+#define HISI_PTT_PMU_NAME "hisi_ptt"
+#define HISI_PTT_AUXTRACE_PRIV_SIZE_LEGACY sizeof(u64)
+#define HISI_PTT_AUXTRACE_PRIV_SIZE_V1 (2 * sizeof(u64))
+#define HISI_PTT_AUXTRACE_PRIV_SIZE HISI_PTT_AUXTRACE_PRIV_SIZE_V1
+#define HISI_PTT_PMU_PATTERN_MASK GENMASK_ULL(39, 36)
struct auxtrace_record *hisi_ptt_recording_init(int *err,
struct perf_pmu *hisi_ptt_pmu);
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread