* [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning
@ 2026-09-08 14:05 Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 1/8] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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
The original hisi-ptt-decoder only prints raw hex values with generic field
names for DW0/DW1/DW2/DW3, without classifying TLP types or decoding
DW0/DW1/DW2/DW3 fields according to the hardware-defined packet format.
This series enhances the HiSilicon PTT (PCIe Trace and Tuning) packet
decoder in perf tool to provide detailed field-level parsing of TLP headers
based on message type, and adds a versioning mechanism for backward
compatibility both in hisi_ptt driver and perf tool.
---
Changes in v4:
- Add missing space in hisi-ptt.rst (Sashiko).
- Widen the pattern bit field in struct hisi_ptt_trace_ctrl (Sashiko).
- Add protocol defined TLP header length parsing in patch 05/08.
- Add MRd and DMRr message types parsing in patch 05/08.
- Add comment for enum hisi_ptt_pkt_msg_type in patch 05/08.
- Add DW0 and DW1 fields analysing in patch 06/08.
- Refine bit-fields parsing of DW0/DW1/DW2/DW3 based on different requests
in patch 06/08.
- Refine the description of pattern=1 in the document in patch 07/08.
- Extract the bit-field printing of v1 version into functions in
patch 08/08.
- Link to v3: https://lore.kernel.org/linux-pci/20260903075241.1445338-1-liusizhe5@huawei.com/
Changes in v3:
- Add explicit inclusion of <stdbool.h> (Sashiko).
- Make patch 07/08 apply cleanly to mainline (Yushan).
- Pick up the reviewed-by tag (Yushan).
- Link to v2: https://lore.kernel.org/linux-pci/20260827140442.2031128-1-liusizhe5@huawei.com/
Changes in v2:
- Split patch 01/10 and patch 02/10 from series v1 into independent patch
series for backporting (Bjorn).
- Use bitwise operations instead of C bitfields for cross-platform cases
(Sashiko).
- Add `pattern` parameter in hisi_ptt driver for layout compatibility.
- Link to v1: https://lore.kernel.org/linux-pci/20260604075005.2219785-1-liusizhe5@huawei.com/
---
Sizhe Liu (8):
perf hisi-ptt: Abstract trace data buf and offset
perf hisi-ptt: Complete the field names for 4DW and 8DW packets
perf hisi-ptt: Extract the raw data printing part
perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing
perf hisi-ptt: Add parsing of supported message types and proto length
perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3
hwtracing: hisi_ptt: Add pattern PMU config for trace format selection
perf hisi-ptt: Pass pattern version to decoder for compatibility
Documentation/trace/hisi-ptt.rst | 26 +-
drivers/hwtracing/ptt/hisi_ptt.c | 25 +-
drivers/hwtracing/ptt/hisi_ptt.h | 4 +
tools/perf/arch/arm64/util/hisi-ptt.c | 18 +
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 593 ++++++++++++++++--
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 241 ++++++-
tools/perf/util/hisi-ptt.c | 51 +-
tools/perf/util/hisi-ptt.h | 9 +-
8 files changed, 872 insertions(+), 95 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 1/8] perf hisi-ptt: Abstract trace data buf and offset
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
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] 11+ messages in thread
* [PATCH v4 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 1/8] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 3/8] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
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] 11+ messages in thread
* [PATCH v4 3/8] perf hisi-ptt: Extract the raw data printing part
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 1/8] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
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] 11+ messages in thread
* [PATCH v4 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (2 preceding siblings ...)
2026-09-08 14:05 ` [PATCH v4 3/8] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 5/8] perf hisi-ptt: Add parsing of supported message types and proto length Sizhe Liu
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
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] 11+ messages in thread
* [PATCH v4 5/8] perf hisi-ptt: Add parsing of supported message types and proto length
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (3 preceding siblings ...)
2026-09-08 14:05 ` [PATCH v4 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 6/8] perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3 Sizhe Liu
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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:
- MRd (Non-posted Memory Read request)
- MWr (Posted Memory Write request)
- DMWr (Posted Deferrable Memory write request)
- Msg (Posted Message request)
- Atom (Non-Posted AtomicOP 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
DW1, DW2 and DW3 printing.
Classify protocol defined header length by Format field, according to PCIe
r6.4 sec 2.2.1.1.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 89 +++++++++++++++++++
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 40 ++++++++-
tools/perf/util/hisi-ptt.c | 1 +
3 files changed, 126 insertions(+), 4 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 00bd9309df68..c9515676ba5c 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,94 @@ 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_mrd_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0 || format == 0x1) && (type == 0);
+}
+
+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_dmwr_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0x2 || format == 0x3) && (type == 0x1b);
+}
+
+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 format, uint32_t type)
+{
+ if (hisi_ptt_is_mrd_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_MRD;
+ else if (hisi_ptt_is_mwr_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_MWR;
+ else if (hisi_ptt_is_dmwr_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_DMWR;
+ 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 int hisi_ptt_parse_pkt_header_proto_len(uint32_t format)
+{
+ if (format & 0x1)
+ return HISI_PTT_4DW_HEADER_PROTO_LEN;
+
+ return HISI_PTT_3DW_HEADER_PROTO_LEN;
+}
+
+static void hisi_ptt_parse_pkt_info(struct hisi_ptt_pkt_buf *pkt_buf,
+ uint32_t dw)
+{
+ uint32_t format, type;
+
+ format = (pkt_buf->pkt_type == HISI_PTT_4DW_PKT) ?
+ FIELD_GET(HISI_PTT_HEAD0_4DW_FORMAT, dw) :
+ FIELD_GET(HISI_PTT_HEAD0_8DW_FORMAT, dw);
+ type = (pkt_buf->pkt_type == HISI_PTT_4DW_PKT) ?
+ FIELD_GET(HISI_PTT_HEAD0_4DW_TYPE, dw) :
+ FIELD_GET(HISI_PTT_HEAD0_8DW_TYPE, dw);
+
+ pkt_buf->pkt_msg_type = hisi_ptt_parse_pkt_msg_type(format, type);
+ pkt_buf->proto_len = hisi_ptt_parse_pkt_header_proto_len(format);
+}
+
static void hisi_ptt_print_raw_record(size_t offset, uint32_t value)
{
const char *color = PERF_COLOR_BLUE;
@@ -114,6 +202,7 @@ 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);
+ hisi_ptt_parse_pkt_info(pkt_buf, dw);
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..f02ba29dfe00 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
@@ -7,15 +7,18 @@
#ifndef INCLUDE__HISI_PTT_PKT_DECODER_H__
#define INCLUDE__HISI_PTT_PKT_DECODER_H__
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <linux/bits.h>
#include <linux/bitfield.h>
-#define HISI_PTT_8DW_CHECK_MASK GENMASK(31, 11)
-#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_8DW_CHECK_MASK GENMASK_U32(31, 11)
+#define HISI_PTT_IS_8DW_PKT GENMASK_U32(31, 11)
+#define HISI_PTT_MAX_SPACE_LEN 10
+#define HISI_PTT_FIELD_LENGTH 4
+#define HISI_PTT_3DW_HEADER_PROTO_LEN 3
+#define HISI_PTT_4DW_HEADER_PROTO_LEN 4
/* Header DW0 fields for 4DW format */
#define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0)
@@ -27,6 +30,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 +45,36 @@ static int hisi_ptt_pkt_size[] = {
[HISI_PTT_8DW_PKT] = 32,
};
+enum hisi_ptt_pkt_msg_type {
+ /* Types do not support analysis */
+ HISI_PTT_PKT_TYPE_UNKNOWN,
+ /* NP-(Memory Read requset: MRd) */
+ HISI_PTT_PKT_TYPE_MRD,
+ /* P-(Memory write request: MWr) */
+ HISI_PTT_PKT_TYPE_MWR,
+ /* P-(Deferrable Memory write request: DMWr) */
+ HISI_PTT_PKT_TYPE_DMWR,
+ /* P-(Message request: Msg, MsgD) */
+ HISI_PTT_PKT_TYPE_MSG,
+ /* NP-(AtomicOP request: FetchAdd, Swap, CAS) */
+ HISI_PTT_PKT_TYPE_ATOM,
+ /* NP-(I/O request: IORd, IOWr) */
+ HISI_PTT_PKT_TYPE_IO,
+ /* NP-(Configuration request: CfgRd0, CfgWr0, CfgRd1, CfgWr1) */
+ HISI_PTT_PKT_TYPE_CFG,
+ /* CPL-(Completion: Cpl, CplD) */
+ HISI_PTT_PKT_TYPE_CPL,
+ /* Type max in enumeration*/
+ 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;
+ size_t proto_len;
};
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] 11+ messages in thread
* [PATCH v4 6/8] perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (4 preceding siblings ...)
2026-09-08 14:05 ` [PATCH v4 5/8] perf hisi-ptt: Add parsing of supported message types and proto length Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Sizhe Liu
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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 DW0, DW1, DW2 and DW3 of the TLP,
separating the layout for different requests. The message type parsed in
the previous patch is used to select the corresponding field layout.
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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 386 +++++++++++++++++-
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 194 ++++++++-
2 files changed, 545 insertions(+), 35 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 c9515676ba5c..482a50c2e9f5 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
@@ -196,9 +196,42 @@ 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_4dw_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %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));
+}
+
+static void hisi_ptt_print_head0_8dw_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Format",
+ FIELD_GET(HISI_PTT_HEAD0_8DW_FORMAT, dw),
+ "Type", FIELD_GET(HISI_PTT_HEAD0_8DW_TYPE, dw),
+ "T9", FIELD_GET(HISI_PTT_HEAD0_8DW_T9, dw),
+ "TC", FIELD_GET(HISI_PTT_HEAD0_8DW_TC, dw),
+ "T8", FIELD_GET(HISI_PTT_HEAD0_8DW_T8, dw),
+ "A2", FIELD_GET(HISI_PTT_HEAD0_8DW_A2, dw),
+ "LN", FIELD_GET(HISI_PTT_HEAD0_8DW_LN, dw),
+ "TH", FIELD_GET(HISI_PTT_HEAD0_8DW_TH, dw),
+ "TD", FIELD_GET(HISI_PTT_HEAD0_8DW_TD, dw),
+ "EP", FIELD_GET(HISI_PTT_HEAD0_8DW_EP, dw),
+ "Attr<1:0>", FIELD_GET(HISI_PTT_HEAD0_8DW_ATTR_1_0, dw),
+ "AT", FIELD_GET(HISI_PTT_HEAD0_8DW_AT, dw),
+ "Length", FIELD_GET(HISI_PTT_HEAD0_8DW_LEN, dw));
+}
+
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);
@@ -206,24 +239,323 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
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));
+ hisi_ptt_print_head0_4dw_fields(dw);
+ else if (pkt_buf->pkt_type == HISI_PTT_8DW_PKT)
+ hisi_ptt_print_head0_8dw_fields(dw);
else
- color_fprintf(stdout, color, " %s\n",
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n",
hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0]);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
+static void hisi_ptt_print_head1_ar64_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x\n",
+ "Requester ID", FIELD_GET(HISI_PTT_HEAD1_AR64_REQ_ID, dw),
+ "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_AR64_TAG_7_0, dw),
+ "Last DW BE",
+ FIELD_GET(HISI_PTT_HEAD1_AR64_LAST_DW_BE, dw),
+ "First DW BE",
+ FIELD_GET(HISI_PTT_HEAD1_AR64_FIRST_DW_BE, dw));
+}
+
+static void hisi_ptt_print_head1_ar32_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x\n",
+ "Requester ID", FIELD_GET(HISI_PTT_HEAD1_AR32_REQ_ID, dw),
+ "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_AR32_TAG_7_0, dw),
+ "Last DW BE",
+ FIELD_GET(HISI_PTT_HEAD1_AR32_LAST_DW_BE, dw),
+ "First DW BE",
+ FIELD_GET(HISI_PTT_HEAD1_AR32_FIRST_DW_BE, dw));
+}
+
+static void hisi_ptt_print_head1_cfg_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x\n",
+ "Requester ID", FIELD_GET(HISI_PTT_HEAD1_CFG_REQ_ID, dw),
+ "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_CFG_TAG_7_0, dw),
+ "Last DW BE",
+ FIELD_GET(HISI_PTT_HEAD1_CFG_LAST_DW_BE, dw),
+ "First DW BE",
+ FIELD_GET(HISI_PTT_HEAD1_CFG_FIRST_DW_BE, dw));
+}
+
+static void hisi_ptt_print_head1_cpl_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x\n",
+ "Completer ID", FIELD_GET(HISI_PTT_HEAD1_CPL_COM_ID, dw),
+ "Cpl Status", FIELD_GET(HISI_PTT_HEAD1_CPL_STA, dw),
+ "BCM", FIELD_GET(HISI_PTT_HEAD1_CPL_BCM, dw),
+ "Byte Count", FIELD_GET(HISI_PTT_HEAD1_CPL_BYTE_CNT, dw));
+}
+
+static void hisi_ptt_print_head1_msg_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x\n",
+ "Requester ID", FIELD_GET(HISI_PTT_HEAD1_MSG_REQ_ID, dw),
+ "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_MSG_TAG_7_0, dw),
+ "Message Code", FIELD_GET(HISI_PTT_HEAD1_MSG_CODE, dw));
+}
+
+static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ uint32_t dw;
+
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw);
+
+ switch (pkt_buf->pkt_msg_type) {
+ case HISI_PTT_PKT_TYPE_MRD:
+ case HISI_PTT_PKT_TYPE_MWR:
+ case HISI_PTT_PKT_TYPE_DMWR:
+ case HISI_PTT_PKT_TYPE_ATOM:
+ case HISI_PTT_PKT_TYPE_IO:
+ if (pkt_buf->proto_len == HISI_PTT_4DW_HEADER_PROTO_LEN)
+ hisi_ptt_print_head1_ar64_fields(dw);
+ else
+ hisi_ptt_print_head1_ar32_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_CFG:
+ hisi_ptt_print_head1_cfg_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_CPL:
+ hisi_ptt_print_head1_cpl_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_MSG:
+ hisi_ptt_print_head1_msg_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_UNKNOWN:
+ case HISI_PTT_PKT_TYPE_MAX:
+ default:
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %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]);
+ break;
+ }
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
+static void hisi_ptt_print_head2_ar64_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "RSV2", FIELD_GET(HISI_PTT_HEAD2_AR64_RSV2, dw),
+ "Request Segment",
+ FIELD_GET(HISI_PTT_HEAD2_AR64_REQ_SEG, dw),
+ "RSV1", FIELD_GET(HISI_PTT_HEAD2_AR64_RSV1, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD2_AR64_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD2_AR64_T, dw),
+ "Tag<13:10>",
+ FIELD_GET(HISI_PTT_HEAD2_AR64_TAG_13_10, dw),
+ "Addr<47:32>",
+ FIELD_GET(HISI_PTT_HEAD2_AR64_ADDR_47_32, dw));
+}
+
+static void hisi_ptt_print_head2_ar32_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x\n",
+ "Addr<31:2>",
+ FIELD_GET(HISI_PTT_HEAD2_AR32_ADDR_31_2, dw),
+ "PH<1:0>", FIELD_GET(HISI_PTT_HEAD2_AR32_PH_1_0, dw));
+}
+
+static void hisi_ptt_print_head2_io_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x\n",
+ "Addr<31:2>",
+ FIELD_GET(HISI_PTT_HEAD2_AR32_ADDR_31_2, dw),
+ "Reserved", FIELD_GET(HISI_PTT_HEAD2_AR32_IO_RSV, dw));
+}
+
+static void hisi_ptt_print_head2_cfg_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x %s %x\n",
+ "Destination ID",
+ FIELD_GET(HISI_PTT_HEAD2_CFG_DST_ID, dw),
+ "RSV2", FIELD_GET(HISI_PTT_HEAD2_CFG_RSV2, dw),
+ "Ext Reg Num",
+ FIELD_GET(HISI_PTT_HEAD2_CFG_REG_NUM_EXT, dw),
+ "Register Number",
+ FIELD_GET(HISI_PTT_HEAD2_CFG_REG_NUM, dw),
+ "RSV1", FIELD_GET(HISI_PTT_HEAD2_CFG_RSV1, dw));
+}
+
+static void hisi_ptt_print_head2_cpl_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x\n",
+ "Requester ID", FIELD_GET(HISI_PTT_HEAD2_CPL_REQ_ID, dw),
+ "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD2_CPL_TAG_7_0, dw),
+ "Reserved", FIELD_GET(HISI_PTT_HEAD2_CPL_RSV, dw),
+ "Lower Address",
+ FIELD_GET(HISI_PTT_HEAD2_CPL_LO_ADDR, dw));
+}
+
+static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ uint32_t dw;
+
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw);
+
+ switch (pkt_buf->pkt_msg_type) {
+ case HISI_PTT_PKT_TYPE_MRD:
+ case HISI_PTT_PKT_TYPE_MWR:
+ case HISI_PTT_PKT_TYPE_DMWR:
+ case HISI_PTT_PKT_TYPE_ATOM:
+ if (pkt_buf->proto_len == HISI_PTT_4DW_HEADER_PROTO_LEN)
+ hisi_ptt_print_head2_ar64_fields(dw);
+ else
+ hisi_ptt_print_head2_ar32_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_IO:
+ hisi_ptt_print_head2_io_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_CFG:
+ hisi_ptt_print_head2_cfg_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_CPL:
+ hisi_ptt_print_head2_cpl_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_MSG:
+ case HISI_PTT_PKT_TYPE_UNKNOWN:
+ case HISI_PTT_PKT_TYPE_MAX:
+ default:
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %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]);
+ break;
+ }
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
+static void hisi_ptt_print_head3_ar64_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x\n",
+ "Addr<31:2>",
+ FIELD_GET(HISI_PTT_HEAD3_AR64_ADDR_31_2, dw),
+ "PH<1:0>", FIELD_GET(HISI_PTT_HEAD3_AR64_PH_1_0, dw));
+}
+
+static void hisi_ptt_print_head3_ar32_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Request Segment",
+ FIELD_GET(HISI_PTT_HEAD3_AR32_REQ_SEG, dw),
+ "ST<15:8>", FIELD_GET(HISI_PTT_HEAD3_AR32_ST_15_8, dw),
+ "RSV2", FIELD_GET(HISI_PTT_HEAD3_AR32_RSV2, dw),
+ "HV", FIELD_GET(HISI_PTT_HEAD3_AR32_HV, dw),
+ "AMA", FIELD_GET(HISI_PTT_HEAD3_AR32_AMA, dw),
+ "AV", FIELD_GET(HISI_PTT_HEAD3_AR32_AV, dw),
+ "FM", FIELD_GET(HISI_PTT_HEAD3_AR32_FM, dw),
+ "RSV1", FIELD_GET(HISI_PTT_HEAD3_AR32_RSV1, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_AR32_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_AR32_T, dw),
+ "Tag<13:10>",
+ FIELD_GET(HISI_PTT_HEAD3_AR32_TAG_13_10, dw));
+}
+
+static void hisi_ptt_print_head3_io_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Request Segment",
+ FIELD_GET(HISI_PTT_HEAD3_AR32_REQ_SEG, dw),
+ "RSV2", FIELD_GET(HISI_PTT_HEAD3_AR32_IO_RSV2, dw),
+ "FM", FIELD_GET(HISI_PTT_HEAD3_AR32_FM, dw),
+ "RSV1", FIELD_GET(HISI_PTT_HEAD3_AR32_RSV1, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_AR32_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_AR32_T, dw),
+ "Tag<13:10>",
+ FIELD_GET(HISI_PTT_HEAD3_AR32_TAG_13_10, dw));
+}
+
+static void hisi_ptt_print_head3_cfg_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "RSV2", FIELD_GET(HISI_PTT_HEAD3_CFG_RSV2, 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<13:10>", FIELD_GET(HISI_PTT_HEAD3_CFG_TAG_13_10, dw),
+ "RSV1", FIELD_GET(HISI_PTT_HEAD3_CFG_RSV1, dw));
+}
+
+static void hisi_ptt_print_head3_cpl_fields(uint32_t dw)
+{
+ color_fprintf(stdout, PERF_COLOR_BLUE,
+ " %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_COM_SEG, dw),
+ "DSV", FIELD_GET(HISI_PTT_HEAD3_CPL_DSV, dw),
+ "Reserved", FIELD_GET(HISI_PTT_HEAD3_CPL_RSV, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_CPL_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_CPL_T, dw),
+ "Tag<13:10>",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_TAG_13_10, dw));
+}
+
+static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ uint32_t dw;
+
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw);
+
+ switch (pkt_buf->pkt_msg_type) {
+ case HISI_PTT_PKT_TYPE_MRD:
+ case HISI_PTT_PKT_TYPE_MWR:
+ case HISI_PTT_PKT_TYPE_DMWR:
+ case HISI_PTT_PKT_TYPE_ATOM:
+ if (pkt_buf->proto_len == HISI_PTT_4DW_HEADER_PROTO_LEN)
+ hisi_ptt_print_head3_ar64_fields(dw);
+ else
+ hisi_ptt_print_head3_ar32_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_IO:
+ hisi_ptt_print_head3_io_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_CFG:
+ hisi_ptt_print_head3_cfg_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_CPL:
+ hisi_ptt_print_head3_cpl_fields(dw);
+ break;
+ case HISI_PTT_PKT_TYPE_MSG:
+ case HISI_PTT_PKT_TYPE_UNKNOWN:
+ case HISI_PTT_PKT_TYPE_MAX:
+ default:
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %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]);
+ break;
+ }
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
@@ -235,12 +567,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];
@@ -248,12 +592,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 f02ba29dfe00..5f71cfdcb7a7 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
@@ -20,19 +20,187 @@
#define HISI_PTT_3DW_HEADER_PROTO_LEN 3
#define HISI_PTT_4DW_HEADER_PROTO_LEN 4
-/* Header DW0 fields for 4DW format */
-#define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0)
-#define HISI_PTT_HEAD0_4DW_LEN GENMASK_U32(20, 11)
-#define HISI_PTT_HEAD0_4DW_SO BIT_U32(21)
-#define HISI_PTT_HEAD0_4DW_TH BIT_U32(22)
-#define HISI_PTT_HEAD0_4DW_T8 BIT_U32(23)
-#define HISI_PTT_HEAD0_4DW_T9 BIT_U32(24)
-#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)
+/* Hisi PTT Header DW0 fields for 4DW format
+ *
+ * bits [31:30] [ 29:25 ][24][23][22][21][ 20:11 ][ 10:0 ]
+ * |-----|---------|---|---|---|---|-------------|-------------|
+ * DW0 [ Fmt ][ Type ][T9][T8][TH][SO][ Length ][ Time ]
+ */
+#define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0)
+#define HISI_PTT_HEAD0_4DW_LEN GENMASK_U32(20, 11)
+#define HISI_PTT_HEAD0_4DW_SO BIT_U32(21)
+#define HISI_PTT_HEAD0_4DW_TH BIT_U32(22)
+#define HISI_PTT_HEAD0_4DW_T8 BIT_U32(23)
+#define HISI_PTT_HEAD0_4DW_T9 BIT_U32(24)
+#define HISI_PTT_HEAD0_4DW_TYPE GENMASK_U32(29, 25)
+#define HISI_PTT_HEAD0_4DW_FORMAT GENMASK_U32(31, 30)
+
+/* Hisi PTT Header DW0 fields for 8DW format
+ *
+ * bits [31:29][28:24][23][22:20][19][18][17][16][15][14][ 13:12 ][11:10][ 9:0 ]
+ * |------|------|---|------|---|---|---|---|---|---|----------|------|-----------|
+ * DW0 [ Fmt ][Type] [T9][ TC ] [T8][A2][LN][TH][TD][EP][ATTR<1:0>][ AT ] [ Length ]
+ */
+#define HISI_PTT_HEAD0_8DW_LEN GENMASK_U32(9, 0)
+#define HISI_PTT_HEAD0_8DW_AT GENMASK_U32(11, 10)
+#define HISI_PTT_HEAD0_8DW_ATTR_1_0 GENMASK_U32(13, 12)
+#define HISI_PTT_HEAD0_8DW_EP BIT_U32(14)
+#define HISI_PTT_HEAD0_8DW_TD BIT_U32(15)
+#define HISI_PTT_HEAD0_8DW_TH BIT_U32(16)
+#define HISI_PTT_HEAD0_8DW_LN BIT_U32(17)
+#define HISI_PTT_HEAD0_8DW_A2 BIT_U32(18)
+#define HISI_PTT_HEAD0_8DW_T8 BIT_U32(19)
+#define HISI_PTT_HEAD0_8DW_TC GENMASK_U32(22, 20)
+#define HISI_PTT_HEAD0_8DW_T9 BIT_U32(23)
+#define HISI_PTT_HEAD0_8DW_TYPE GENMASK_U32(28, 24)
+#define HISI_PTT_HEAD0_8DW_FORMAT GENMASK_U32(31, 29)
+
+/* Hisi PTT Header DW1/DW2/DW3 fields for 64-bit Address-Based Routing TLPs
+ * Used with Memory rd/wr DMWr and AtomicOp Requests.
+ *
+ * bits [ 31:16 ][ 15:8 ][ 7:4 ][ 3:0 ]
+ * |-------------|---------|-----------|-----------|
+ * DW1 [Requester ID][Tag<7:0>][Last DW BE][First DW BE]
+ *
+ * bits [ 31 ][ 30:23 ][ 22 ][21][20][ 19:16 ][ 15:0 ]
+ * |---------|----------------|-----|---|--|-----------|--------------|
+ * DW2 [ RSV2 ][Request Segment][RSV1][TV][T][Tag<13:10>][Address<47:32>]
+ *
+ * bits [ 31:2 ][ 1:0 ]
+ * |--------------|-------|
+ * DW3 [Address<31:2>][PH<1:0>]
+ */
+#define HISI_PTT_HEAD1_AR64_REQ_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD1_AR64_TAG_7_0 GENMASK_U32(15, 8)
+#define HISI_PTT_HEAD1_AR64_LAST_DW_BE GENMASK_U32(7, 4)
+#define HISI_PTT_HEAD1_AR64_FIRST_DW_BE GENMASK_U32(3, 0)
+#define HISI_PTT_HEAD2_AR64_RSV2 BIT_U32(31)
+#define HISI_PTT_HEAD2_AR64_REQ_SEG GENMASK_U32(30, 23)
+#define HISI_PTT_HEAD2_AR64_RSV1 BIT_U32(22)
+#define HISI_PTT_HEAD2_AR64_TV BIT_U32(21)
+#define HISI_PTT_HEAD2_AR64_T BIT_U32(20)
+#define HISI_PTT_HEAD2_AR64_TAG_13_10 GENMASK_U32(19, 16)
+#define HISI_PTT_HEAD2_AR64_ADDR_47_32 GENMASK_U32(15, 0)
+#define HISI_PTT_HEAD3_AR64_ADDR_31_2 GENMASK_U32(31, 2)
+#define HISI_PTT_HEAD3_AR64_PH_1_0 GENMASK_U32(1, 0)
+
+/* Hisi PTT Header DW1/DW2/DW3 fields for 32-bit Address-Based Routing TLPs
+ * Used with Memory rd/wr DMWr, AtomicOp and I/O Requests.
+ *
+ * bits [ 31:16 ][ 15:8 ][ 7:4 ][ 3:0 ]
+ * |-------------|---------|-----------|-----------|
+ * DW1 [Requester ID][Tag<7:0>][Last DW BE][First DW BE]
+ *
+ * For Memory rd/wr DMWr and AtomicOp Requests
+ * bits [ 31:2 ][ 1:0 ]
+ * |--------------|-------|
+ * DW2 [Address<31:2>][PH<1:0>]
+ *
+ * For I/O Transactions
+ * bits [ 31:2 ][ 1:0 ]
+ * |--------------|--------|
+ * DW2 [Address<31:2>][Reserved]
+ *
+ * For Memory rd/wr DMWr and AtomicOp Requests
+ * bits [ 31:24 ][ 23:16 ][ 15:14 ][13:12][11:9] [8 ][7 ][ 6 ][5 ][4][ 3:0 ]
+ * |-----------------|---------|--------|------|------|---|---|-----|---|--|----------|
+ * DW3 [Request Segments][ST<15:8>][ RSV2 ][ HV ][ AMA ][AV][FM][RSV1][TV][T][Tag<13:10>]
+ *
+ * For I/O Transactions
+ * bits [ 31:24 ][ 23:8 ][7 ][ 6 ][5 ][4][ 3:0 ]
+ * |-----------------|---------|---|-----|---|--|----------|
+ * DW3 [Request Segments][ RSV2 ][FM][RSV1][TV][T][Tag<13:10>]
+ */
+#define HISI_PTT_HEAD1_AR32_REQ_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD1_AR32_TAG_7_0 GENMASK_U32(15, 8)
+#define HISI_PTT_HEAD1_AR32_LAST_DW_BE GENMASK_U32(7, 4)
+#define HISI_PTT_HEAD1_AR32_FIRST_DW_BE GENMASK_U32(3, 0)
+#define HISI_PTT_HEAD2_AR32_ADDR_31_2 GENMASK_U32(31, 2)
+#define HISI_PTT_HEAD2_AR32_PH_1_0 GENMASK_U32(1, 0)
+#define HISI_PTT_HEAD2_AR32_IO_RSV GENMASK_U32(1, 0)
+#define HISI_PTT_HEAD3_AR32_REQ_SEG GENMASK_U32(31, 24)
+#define HISI_PTT_HEAD3_AR32_ST_15_8 GENMASK_U32(23, 16)
+#define HISI_PTT_HEAD3_AR32_RSV2 GENMASK_U32(15, 14)
+#define HISI_PTT_HEAD3_AR32_HV GENMASK_U32(13, 12)
+#define HISI_PTT_HEAD3_AR32_AMA GENMASK_U32(11, 9)
+#define HISI_PTT_HEAD3_AR32_AV BIT_U32(8)
+#define HISI_PTT_HEAD3_AR32_FM BIT_U32(7)
+#define HISI_PTT_HEAD3_AR32_RSV1 BIT_U32(6)
+#define HISI_PTT_HEAD3_AR32_TV BIT_U32(5)
+#define HISI_PTT_HEAD3_AR32_T BIT_U32(4)
+#define HISI_PTT_HEAD3_AR32_TAG_13_10 GENMASK_U32(3, 0)
+#define HISI_PTT_HEAD3_AR32_IO_RSV2 GENMASK_U32(23, 8)
+
+/* Hisi PTT Header DW1/DW2/DW3 fields for Configuration Requests
+ *
+ * bits [ 31:16 ][ 15:8 ][ 7:4 ][ 3:0 ]
+ * |-------------|---------|-----------|-----------|
+ * DW1 [Requester ID][Tag<7:0>][Last DW BE][First DW BE]
+ *
+ * bits [ 31:16 ][ 15:12 ][ 11:8 ][ 7:2 ][ 1:0]
+ * |--------------|---------|------------|----------------|----|
+ * DW2 [Destination ID][ RSV2 ][Ext Reg Num][Register Number][RSV1]
+ *
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|--------------------|----|---|--|-----------|----------|
+ * DW3 [ RSV2 ][Destination Segment][DSV][TV][T][Tag<13:10>][ RSV1 ]
+ */
+#define HISI_PTT_HEAD1_CFG_REQ_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD1_CFG_TAG_7_0 GENMASK_U32(15, 8)
+#define HISI_PTT_HEAD1_CFG_LAST_DW_BE GENMASK_U32(7, 4)
+#define HISI_PTT_HEAD1_CFG_FIRST_DW_BE GENMASK_U32(3, 0)
+#define HISI_PTT_HEAD2_CFG_DST_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD2_CFG_RSV2 GENMASK_U32(15, 12)
+#define HISI_PTT_HEAD2_CFG_REG_NUM_EXT GENMASK_U32(11, 8)
+#define HISI_PTT_HEAD2_CFG_REG_NUM GENMASK_U32(7, 2)
+#define HISI_PTT_HEAD2_CFG_RSV1 GENMASK_U32(1, 0)
+#define HISI_PTT_HEAD3_CFG_RSV2 BIT_U32(31)
+#define HISI_PTT_HEAD3_CFG_DST_SEG GENMASK_U32(30, 23)
+#define HISI_PTT_HEAD3_CFG_DSV BIT_U32(22)
+#define HISI_PTT_HEAD3_CFG_TV BIT_U32(21)
+#define HISI_PTT_HEAD3_CFG_T BIT_U32(20)
+#define HISI_PTT_HEAD3_CFG_TAG_13_10 GENMASK_U32(19, 16)
+#define HISI_PTT_HEAD3_CFG_RSV1 GENMASK_U32(15, 0)
+
+/* Hisi PTT Header DW1/DW2/DW3 fields for Completion TLPs
+ *
+ * bits [ 31:16 ][ 15:13 ][12 ][ 11:0 ]
+ * |-------------|-----------|----|----------|
+ * DW1 [Completer ID][Cpl Status][BCM][Byte Count]
+ *
+ * bits [ 31:16 ][ 15:8 ][ 7 ][ 6:0 ]
+ * |-------------|---------|----|-------------|
+ * DW2 [Requester ID][Tag<7:0>][RSV][Lower Address]
+ *
+ * bits [ 31:24 ][ 23:16 ][15 ][ 14:6][5][4 ][ 3:0 ]
+ * |--------------------|------------------|----|------|--|---|----------|
+ * DW3 [Destination Segment][Completer Segment][DSV][ RSV ][TV][T][Tag<13:10>]
+ */
+#define HISI_PTT_HEAD1_CPL_COM_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD1_CPL_STA GENMASK_U32(15, 13)
+#define HISI_PTT_HEAD1_CPL_BCM BIT_U32(12)
+#define HISI_PTT_HEAD1_CPL_BYTE_CNT GENMASK_U32(11, 0)
+#define HISI_PTT_HEAD2_CPL_REQ_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD2_CPL_TAG_7_0 GENMASK_U32(15, 8)
+#define HISI_PTT_HEAD2_CPL_RSV BIT_U32(7)
+#define HISI_PTT_HEAD2_CPL_LO_ADDR GENMASK_U32(6, 0)
+#define HISI_PTT_HEAD3_CPL_DST_SEG GENMASK_U32(31, 24)
+#define HISI_PTT_HEAD3_CPL_COM_SEG GENMASK_U32(23, 16)
+#define HISI_PTT_HEAD3_CPL_DSV BIT_U32(15)
+#define HISI_PTT_HEAD3_CPL_RSV GENMASK_U32(14, 6)
+#define HISI_PTT_HEAD3_CPL_TV BIT_U32(5)
+#define HISI_PTT_HEAD3_CPL_T BIT_U32(4)
+#define HISI_PTT_HEAD3_CPL_TAG_13_10 GENMASK_U32(3, 0)
+
+/* Hisi PTT Header DW1 fields for Message Requests
+ *
+ * bits [ 31:16 ][ 15:8 ][ 7:0 ]
+ * |-------------|---------|------------|
+ * DW1 [Requester ID][Tag<7:0>][Message Code]
+ */
+#define HISI_PTT_HEAD1_MSG_REQ_ID GENMASK_U32(31, 16)
+#define HISI_PTT_HEAD1_MSG_TAG_7_0 GENMASK_U32(15, 8)
+#define HISI_PTT_HEAD1_MSG_CODE GENMASK_U32(7, 0)
enum hisi_ptt_pkt_type {
HISI_PTT_4DW_PKT,
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (5 preceding siblings ...)
2026-09-08 14:05 ` [PATCH v4 6/8] perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3 Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Sizhe Liu
2026-09-08 21:02 ` [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Arnaldo Carvalho de Melo
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
Signed-off-by: Sizhe Liu <liusizhe5@huawei.com>
---
Documentation/trace/hisi-ptt.rst | 26 ++++++++++++++++++++++++--
drivers/hwtracing/ptt/hisi_ptt.c | 25 ++++++++++++++++++++++++-
drivers/hwtracing/ptt/hisi_ptt.h | 4 ++++
3 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/Documentation/trace/hisi-ptt.rst b/Documentation/trace/hisi-ptt.rst
index f6a2655f99e5..a70719386159 100644
--- a/Documentation/trace/hisi-ptt.rst
+++ b/Documentation/trace/hisi-ptt.rst
@@ -255,7 +255,29 @@ 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
+ DW0 (in 8DW format), DW1, DW2 and DW3 are printed with generic field names,
+ and no message-type-based field decoding. Consider using legacy trace format
+ when the current PCIe link generation is not higher than PCIe 6.0.
+- 4'b0001: trace format v1
+ DW0, DW1, DW2 and DW3 are decoded according to the TLP message type (MRd,
+ MWr, DMWr, Msg, AtomicOP, I/O, 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 +296,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 52f168f8b459..b63985c2b30e 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -232,6 +232,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;
ctrl->started = true;
@@ -806,12 +810,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
};
@@ -941,6 +947,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;
@@ -991,6 +1006,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)
@@ -1025,7 +1043,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..c1636676c8c8 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:4;
};
/*
--
2.33.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (6 preceding siblings ...)
2026-09-08 14:05 ` [PATCH v4 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Sizhe Liu
@ 2026-09-08 14:05 ` Sizhe Liu
2026-09-08 21:02 ` [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Arnaldo Carvalho de Melo
8 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-08 14:05 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.
Reviewed-by: Yushan Wang <wangyushan12@huawei.com>
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 | 123 ++++++++++++------
.../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, 133 insertions(+), 53 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 482a50c2e9f5..62b98d98b2e9 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_mrd_tlp(uint32_t format, uint32_t type)
{
@@ -230,21 +235,36 @@ static void hisi_ptt_print_head0_8dw_fields(uint32_t dw)
"Length", FIELD_GET(HISI_PTT_HEAD0_8DW_LEN, dw));
}
+static void hisi_ptt_print_head0_fields_v1(struct hisi_ptt_pkt_buf *pkt_buf,
+ uint32_t dw, const char *desc)
+{
+ if (pkt_buf->pkt_type == HISI_PTT_4DW_PKT)
+ hisi_ptt_print_head0_4dw_fields(dw);
+ else if (pkt_buf->pkt_type == HISI_PTT_8DW_PKT)
+ hisi_ptt_print_head0_8dw_fields(dw);
+ else
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc);
+}
+
static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
{
+ const char *desc = pkt_buf->pkt_type == HISI_PTT_4DW_PKT ?
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD0] :
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0];
uint32_t dw;
dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
hisi_ptt_parse_pkt_info(pkt_buf, dw);
hisi_ptt_print_raw_record(pkt_buf->pos, dw);
- if (pkt_buf->pkt_type == HISI_PTT_4DW_PKT)
- hisi_ptt_print_head0_4dw_fields(dw);
- else if (pkt_buf->pkt_type == HISI_PTT_8DW_PKT)
- hisi_ptt_print_head0_8dw_fields(dw);
+ if (pkt_buf->pattern < HISI_PTT_PATTERN_V1) {
+ if (pkt_buf->pkt_type == HISI_PTT_4DW_PKT)
+ hisi_ptt_print_head0_4dw_fields(dw);
+ else
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc);
+ }
else
- color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n",
- hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0]);
+ hisi_ptt_print_head0_fields_v1(pkt_buf, dw, desc);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
@@ -304,13 +324,9 @@ static void hisi_ptt_print_head1_msg_fields(uint32_t dw)
"Message Code", FIELD_GET(HISI_PTT_HEAD1_MSG_CODE, dw));
}
-static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
+static void hisi_ptt_print_head1_fields_v1(struct hisi_ptt_pkt_buf *pkt_buf,
+ uint32_t dw, const char *desc)
{
- uint32_t dw;
-
- dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
- hisi_ptt_print_raw_record(pkt_buf->pos, dw);
-
switch (pkt_buf->pkt_msg_type) {
case HISI_PTT_PKT_TYPE_MRD:
case HISI_PTT_PKT_TYPE_MWR:
@@ -334,12 +350,25 @@ static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
case HISI_PTT_PKT_TYPE_UNKNOWN:
case HISI_PTT_PKT_TYPE_MAX:
default:
- color_fprintf(stdout, PERF_COLOR_BLUE, " %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]);
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc);
break;
}
+}
+
+static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *desc = 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];
+ 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->pattern < HISI_PTT_PATTERN_V1)
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc);
+ else
+ hisi_ptt_print_head1_fields_v1(pkt_buf, dw, desc);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
@@ -403,13 +432,9 @@ static void hisi_ptt_print_head2_cpl_fields(uint32_t dw)
FIELD_GET(HISI_PTT_HEAD2_CPL_LO_ADDR, dw));
}
-static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
+static void hisi_ptt_print_head2_fields_v1(struct hisi_ptt_pkt_buf *pkt_buf,
+ uint32_t dw, const char *desc)
{
- uint32_t dw;
-
- dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
- hisi_ptt_print_raw_record(pkt_buf->pos, dw);
-
switch (pkt_buf->pkt_msg_type) {
case HISI_PTT_PKT_TYPE_MRD:
case HISI_PTT_PKT_TYPE_MWR:
@@ -433,12 +458,25 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
case HISI_PTT_PKT_TYPE_UNKNOWN:
case HISI_PTT_PKT_TYPE_MAX:
default:
- color_fprintf(stdout, PERF_COLOR_BLUE, " %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, PERF_COLOR_BLUE, " %s\n", desc);
break;
}
+}
+
+static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ 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->pattern < HISI_PTT_PATTERN_V1)
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc);
+ else
+ hisi_ptt_print_head2_fields_v1(pkt_buf, dw, desc);
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
@@ -516,13 +554,9 @@ static void hisi_ptt_print_head3_cpl_fields(uint32_t dw)
FIELD_GET(HISI_PTT_HEAD3_CPL_TAG_13_10, dw));
}
-static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
+static void hisi_ptt_print_head3_fields_v1(struct hisi_ptt_pkt_buf *pkt_buf,
+ uint32_t dw, const char *desc)
{
- uint32_t dw;
-
- dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
- hisi_ptt_print_raw_record(pkt_buf->pos, dw);
-
switch (pkt_buf->pkt_msg_type) {
case HISI_PTT_PKT_TYPE_MRD:
case HISI_PTT_PKT_TYPE_MWR:
@@ -546,12 +580,25 @@ static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
case HISI_PTT_PKT_TYPE_UNKNOWN:
case HISI_PTT_PKT_TYPE_MAX:
default:
- color_fprintf(stdout, PERF_COLOR_BLUE, " %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, PERF_COLOR_BLUE, " %s\n", desc);
break;
}
+}
+
+static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ 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->pattern < HISI_PTT_PATTERN_V1)
+ color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc);
+ else
+ hisi_ptt_print_head3_fields_v1(pkt_buf, dw, 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 5f71cfdcb7a7..f17ee6b549ca 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
@@ -19,6 +19,8 @@
#define HISI_PTT_FIELD_LENGTH 4
#define HISI_PTT_3DW_HEADER_PROTO_LEN 3
#define HISI_PTT_4DW_HEADER_PROTO_LEN 4
+#define HISI_PTT_PATTERN_LEGACY 0
+#define HISI_PTT_PATTERN_V1 1
/* Hisi PTT Header DW0 fields for 4DW format
*
@@ -208,11 +210,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 {
/* Types do not support analysis */
HISI_PTT_PKT_TYPE_UNKNOWN,
@@ -243,6 +240,7 @@ struct hisi_ptt_pkt_buf {
enum hisi_ptt_pkt_type pkt_type;
enum hisi_ptt_pkt_msg_type pkt_msg_type;
size_t proto_len;
+ 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] 11+ messages in thread
* Re: [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
` (7 preceding siblings ...)
2026-09-08 14:05 ` [PATCH v4 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Sizhe Liu
@ 2026-09-08 21:02 ` Arnaldo Carvalho de Melo
2026-09-11 6:41 ` Sizhe Liu
8 siblings, 1 reply; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-09-08 21:02 UTC (permalink / raw)
To: Sizhe Liu
Cc: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1, linux-kernel, linux-pci, linux-perf-users,
linux-arm-kernel, linux-doc, linuxarm, prime.zeng
On Tue, Sep 08, 2026 at 10:05:01PM +0800, Sizhe Liu wrote:
> The original hisi-ptt-decoder only prints raw hex values with generic field
> names for DW0/DW1/DW2/DW3, without classifying TLP types or decoding
> DW0/DW1/DW2/DW3 fields according to the hardware-defined packet format.
>
> This series enhances the HiSilicon PTT (PCIe Trace and Tuning) packet
> decoder in perf tool to provide detailed field-level parsing of TLP headers
> based on message type, and adds a versioning mechanism for backward
> compatibility both in hisi_ptt driver and perf tool.
Series is sashiko clean by now, has a Reviewed-by, but it touches both
kernel and tools, I wouldn't have a problem if it was processed by
whoever maintains the kernel part.
- Arnaldo
> ---
> Changes in v4:
> - Add missing space in hisi-ptt.rst (Sashiko).
> - Widen the pattern bit field in struct hisi_ptt_trace_ctrl (Sashiko).
> - Add protocol defined TLP header length parsing in patch 05/08.
> - Add MRd and DMRr message types parsing in patch 05/08.
> - Add comment for enum hisi_ptt_pkt_msg_type in patch 05/08.
> - Add DW0 and DW1 fields analysing in patch 06/08.
> - Refine bit-fields parsing of DW0/DW1/DW2/DW3 based on different requests
> in patch 06/08.
> - Refine the description of pattern=1 in the document in patch 07/08.
> - Extract the bit-field printing of v1 version into functions in
> patch 08/08.
> - Link to v3: https://lore.kernel.org/linux-pci/20260903075241.1445338-1-liusizhe5@huawei.com/
>
> Changes in v3:
> - Add explicit inclusion of <stdbool.h> (Sashiko).
> - Make patch 07/08 apply cleanly to mainline (Yushan).
> - Pick up the reviewed-by tag (Yushan).
> - Link to v2: https://lore.kernel.org/linux-pci/20260827140442.2031128-1-liusizhe5@huawei.com/
>
> Changes in v2:
> - Split patch 01/10 and patch 02/10 from series v1 into independent patch
> series for backporting (Bjorn).
> - Use bitwise operations instead of C bitfields for cross-platform cases
> (Sashiko).
> - Add `pattern` parameter in hisi_ptt driver for layout compatibility.
> - Link to v1: https://lore.kernel.org/linux-pci/20260604075005.2219785-1-liusizhe5@huawei.com/
>
> ---
> Sizhe Liu (8):
> perf hisi-ptt: Abstract trace data buf and offset
> perf hisi-ptt: Complete the field names for 4DW and 8DW packets
> perf hisi-ptt: Extract the raw data printing part
> perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing
> perf hisi-ptt: Add parsing of supported message types and proto length
> perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3
> hwtracing: hisi_ptt: Add pattern PMU config for trace format selection
> perf hisi-ptt: Pass pattern version to decoder for compatibility
>
> Documentation/trace/hisi-ptt.rst | 26 +-
> drivers/hwtracing/ptt/hisi_ptt.c | 25 +-
> drivers/hwtracing/ptt/hisi_ptt.h | 4 +
> tools/perf/arch/arm64/util/hisi-ptt.c | 18 +
> .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 593 ++++++++++++++++--
> .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 241 ++++++-
> tools/perf/util/hisi-ptt.c | 51 +-
> tools/perf/util/hisi-ptt.h | 9 +-
> 8 files changed, 872 insertions(+), 95 deletions(-)
>
> --
> 2.33.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning
2026-09-08 21:02 ` [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Arnaldo Carvalho de Melo
@ 2026-09-11 6:41 ` Sizhe Liu
0 siblings, 0 replies; 11+ messages in thread
From: Sizhe Liu @ 2026-09-11 6:41 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: rostedt, mhiramat, mathieu.desnoyers, corbet, skhan, bhelgaas,
yangyccccc, jic23, john.g.garry, will, james.clark, mike.leach,
leo.yan, peterz, mingo, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, wangyushan12,
wuzongyu1, linux-kernel, linux-pci, linux-perf-users,
linux-arm-kernel, linux-doc, linuxarm, prime.zeng,
Arnaldo Carvalho de Melo
On 2026/9/9 5:02, Arnaldo Carvalho de Melo wrote:
> On Tue, Sep 08, 2026 at 10:05:01PM +0800, Sizhe Liu wrote:
>> The original hisi-ptt-decoder only prints raw hex values with
>> generic field names for DW0/DW1/DW2/DW3, without classifying TLP
>> types or decoding DW0/DW1/DW2/DW3 fields according to the hardware-
>> defined packet format.
>>
>> This series enhances the HiSilicon PTT (PCIe Trace and Tuning) packet
>> decoder in perf tool to provide detailed field-level parsing of TLP
>> headers based on message type, and adds a versioning mechanism for
>> backward compatibility both in hisi_ptt driver and perf tool.
>
> Series is sashiko clean by now, has a Reviewed-by, but it touches both
> kernel and tools, I wouldn't have a problem if it was processed by whoever
> maintains the kernel part.
>
> - Arnaldo
>
Hi Suzuki,
The series is now Sashiko-clean and has Reviewed-by tags. It touches both
driver and tools. Arnaldo is fine with the tools part. Would you mind
reviewing the driver part and picking it up through your tree if it looks good?
If there are any changes needed, please let me know.
Link: https://lore.kernel.org/all/20260908140509.2485649-1-liusizhe5@huawei.com/
Thanks for your time!
Sizhe
>> --- Changes in v4: - Add missing space in hisi-ptt.rst (Sashiko). -
>> Widen the pattern bit field in struct hisi_ptt_trace_ctrl (Sashiko).
>> - Add protocol defined TLP header length parsing in patch 05/08. -
>> Add MRd and DMRr message types parsing in patch 05/08. - Add comment
>> for enum hisi_ptt_pkt_msg_type in patch 05/08. - Add DW0 and DW1
>> fields analysing in patch 06/08. - Refine bit-fields parsing of DW0/
>> DW1/DW2/DW3 based on different requests in patch 06/08. - Refine the
>> description of pattern=1 in the document in patch 07/08. - Extract
>> the bit-field printing of v1 version into functions in patch 08/08. -
>> Link to v3: https://lore.kernel.org/linux-
>> pci/20260903075241.1445338-1-liusizhe5@huawei.com/
>>
>> Changes in v3: - Add explicit inclusion of <stdbool.h> (Sashiko). -
>> Make patch 07/08 apply cleanly to mainline (Yushan). - Pick up the
>> reviewed-by tag (Yushan). - Link to v2: https://lore.kernel.org/
>> linux-pci/20260827140442.2031128-1-liusizhe5@huawei.com/
>>
>> Changes in v2: - Split patch 01/10 and patch 02/10 from series v1
>> into independent patch series for backporting (Bjorn). - Use bitwise
>> operations instead of C bitfields for cross-platform cases (Sashiko).
>> - Add `pattern` parameter in hisi_ptt driver for layout
>> compatibility. - Link to v1: https://lore.kernel.org/linux-
>> pci/20260604075005.2219785-1-liusizhe5@huawei.com/
>>
>> --- Sizhe Liu (8): perf hisi-ptt: Abstract trace data buf and offset
>> perf hisi-ptt: Complete the field names for 4DW and 8DW packets perf
>> hisi-ptt: Extract the raw data printing part perf hisi-ptt: Merge
>> 4DW and 8DW HEAD0 printing perf hisi-ptt: Add parsing of supported
>> message types and proto length perf hisi-ptt: Add field-level
>> parsing for header DW0/DW1/DW2/DW3 hwtracing: hisi_ptt: Add pattern
>> PMU config for trace format selection perf hisi-ptt: Pass pattern
>> version to decoder for compatibility
>>
>> Documentation/trace/hisi-ptt.rst | 26 +- drivers/
>> hwtracing/ptt/hisi_ptt.c | 25 +- drivers/hwtracing/ptt/
>> hisi_ptt.h | 4 + tools/perf/arch/arm64/util/hisi-
>> ptt.c | 18 + .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
>> | 593 ++++++++++++++++-- .../hisi-ptt-decoder/hisi-ptt-pkt-
>> decoder.h | 241 ++++++- tools/perf/util/hisi-
>> ptt.c | 51 +- tools/perf/util/hisi-
>> ptt.h | 9 +- 8 files changed, 872
>> insertions(+), 95 deletions(-)
>>
>> -- 2.33.0
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-09-11 7:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 14:05 [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 1/8] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 3/8] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 5/8] perf hisi-ptt: Add parsing of supported message types and proto length Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 6/8] perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3 Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Sizhe Liu
2026-09-08 14:05 ` [PATCH v4 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Sizhe Liu
2026-09-08 21:02 ` [PATCH v4 0/8] Enhance TLP packet decoder with field-level parsing and versioning Arnaldo Carvalho de Melo
2026-09-11 6:41 ` Sizhe Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox