From: Sizhe Liu <liusizhe5@huawei•com>
To: <rostedt@goodmis•org>, <mhiramat@kernel•org>,
<mathieu.desnoyers@efficios•com>, <corbet@lwn•net>,
<skhan@linuxfoundation•org>, <bhelgaas@google•com>,
<yangyccccc@gmail•com>, <jic23@kernel•org>,
<john.g.garry@oracle•com>, <will@kernel•org>,
<james.clark@linaro•org>, <mike.leach@arm•com>,
<leo.yan@linux•dev>, <peterz@infradead•org>, <mingo@redhat•com>,
<acme@kernel•org>, <namhyung@kernel•org>, <mark.rutland@arm•com>,
<alexander.shishkin@linux•intel.com>, <jolsa@kernel•org>,
<irogers@google•com>, <adrian.hunter@intel•com>,
<wangyushan12@huawei•com>, <shenyang39@huawei•com>,
<gaozhihao6@h-partners•com>, <yuzhichengcheng@h-partners•com>,
<liyihang9@h-partners•com>
Cc: <linux-kernel@vger•kernel.org>, <linux-pci@vger•kernel.org>,
<linux-perf-users@vger•kernel.org>,
<linux-arm-kernel@lists•infradead.org>,
<linux-doc@vger•kernel.org>, <linuxarm@huawei•com>,
<prime.zeng@hisilicon•com>, <fanghao11@huawei•com>,
<wuyifan50@huawei•com>, <liusizhe5@huawei•com>
Subject: [PATCH 02/10] perf hisi-ptt: Fix PTT trace TLP Header parsing
Date: Thu, 4 Jun 2026 15:49:57 +0800 [thread overview]
Message-ID: <20260604075005.2219785-3-liusizhe5@huawei.com> (raw)
In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com>
The DW0 bit field layout of the hisi_ptt_4dw union does not match the
actual bit ordering in little-endian memory, causing incorrect field
extraction. Reorder the struct members from LSB to MSB to match the
le32_to_cpu() conversion.
Also print all DW hex values in big-endian byte order for readability,
matching the bit field layout shown in the format diagram.
4DW format is like:
bits [31:30] [ 29:25 ][24][23][22][21][ 20:11 ][ 10:0 ]
|-----|---------|---|---|---|---|-------------|-------------|
DW0 [ Fmt ][ Type ][T9][T8][TH][SO][ Length ][ Time ]
DW1 [ Header DW1 ]
DW2 [ Header DW2 ]
DW3 [ Header DW3 ]
Cc: stable@vger•kernel.org
Fixes: 5e91e57e6809 ("perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet")
Signed-off-by: Sizhe Liu <liusizhe5@huawei•com>
---
Documentation/trace/hisi-ptt.rst | 28 ++++++++--------
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 33 ++++++++++++-------
2 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/Documentation/trace/hisi-ptt.rst b/Documentation/trace/hisi-ptt.rst
index 6eef28ebb0c7..f6a2655f99e5 100644
--- a/Documentation/trace/hisi-ptt.rst
+++ b/Documentation/trace/hisi-ptt.rst
@@ -285,20 +285,20 @@ according to the format described previously (take 8DW as an example):
[...perf headers and other information]
. ... HISI PTT data: size 4194304 bytes
. 00000000: 00 00 00 00 Prefix
- . 00000004: 01 00 00 60 Header DW0
- . 00000008: 0f 1e 00 01 Header DW1
- . 0000000c: 04 00 00 00 Header DW2
- . 00000010: 40 00 81 02 Header DW3
- . 00000014: 33 c0 04 00 Time
+ . 00000004: 60 00 00 01 Header DW0
+ . 00000008: 01 00 1e 0f Header DW1
+ . 0000000c: 00 00 00 04 Header DW2
+ . 00000010: 02 81 00 40 Header DW3
+ . 00000014: 00 04 c0 33 Time
. 00000020: 00 00 00 00 Prefix
- . 00000024: 01 00 00 60 Header DW0
- . 00000028: 0f 1e 00 01 Header DW1
- . 0000002c: 04 00 00 00 Header DW2
- . 00000030: 40 00 81 02 Header DW3
- . 00000034: 02 00 00 00 Time
+ . 00000024: 60 00 00 01 Header DW0
+ . 00000028: 01 00 1e 0f Header DW1
+ . 0000002c: 00 00 00 04 Header DW2
+ . 00000030: 02 81 00 40 Header DW3
+ . 00000034: 00 00 00 02 Time
. 00000040: 00 00 00 00 Prefix
- . 00000044: 01 00 00 60 Header DW0
- . 00000048: 0f 1e 00 01 Header DW1
- . 0000004c: 04 00 00 00 Header DW2
- . 00000050: 40 00 81 02 Header DW3
+ . 00000044: 60 00 00 01 Header DW0
+ . 00000048: 01 00 1e 0f Header DW1
+ . 0000004c: 00 00 00 04 Header DW2
+ . 00000050: 02 81 00 40 Header DW3
[...]
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 c48b2ce7c4a3..67024f18ebbb 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
@@ -11,6 +11,7 @@
#include <byteswap.h>
#include <linux/bitops.h>
#include <stdarg.h>
+#include <linux/kernel.h>
#include "../color.h"
#include "hisi-ptt-pkt-decoder.h"
@@ -75,14 +76,14 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = {
union hisi_ptt_4dw {
struct {
- uint32_t format : 2;
- uint32_t type : 5;
- uint32_t t9 : 1;
- uint32_t t8 : 1;
- uint32_t th : 1;
- uint32_t so : 1;
- uint32_t len : 10;
uint32_t time : 11;
+ uint32_t len : 10;
+ uint32_t so : 1;
+ uint32_t th : 1;
+ uint32_t t8 : 1;
+ uint32_t t9 : 1;
+ uint32_t type : 5;
+ uint32_t format : 2;
};
uint32_t value;
};
@@ -90,12 +91,17 @@ union hisi_ptt_4dw {
static void hisi_ptt_print_pkt(const unsigned char *buf, int pos, const char *desc)
{
const char *color = PERF_COLOR_BLUE;
+ uint32_t value;
+ uint8_t byte;
int i;
+ value = le32_to_cpu(*(__le32 *)(buf + pos));
printf(".");
color_fprintf(stdout, color, " %08x: ", pos);
- for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++)
- color_fprintf(stdout, color, "%02x ", buf[pos + i]);
+ for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++) {
+ 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, " ");
color_fprintf(stdout, color, " %s\n", desc);
@@ -123,13 +129,16 @@ static void hisi_ptt_4dw_print_dw0(const unsigned char *buf, int pos)
{
const char *color = PERF_COLOR_BLUE;
union hisi_ptt_4dw dw0;
+ uint8_t byte;
int i;
- dw0.value = *(uint32_t *)(buf + pos);
+ dw0.value = le32_to_cpu(*(__le32 *)(buf + pos));
printf(".");
color_fprintf(stdout, color, " %08x: ", pos);
- for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++)
- color_fprintf(stdout, color, "%02x ", buf[pos + i]);
+ for (i = 0; i < HISI_PTT_FIELD_LENGTH; i++) {
+ byte = (dw0.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, " ");
--
2.33.0
next prev parent reply other threads:[~2026-06-04 7:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 7:49 [PATCH 00/10] perf hisi-ptt: Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-06-04 7:49 ` [PATCH 01/10] perf hisi-ptt: Fix spelling and abbreviation errors Sizhe Liu
2026-06-04 7:49 ` Sizhe Liu [this message]
2026-06-04 7:49 ` [PATCH 03/10] perf hisi-ptt: Rename hisi_ptt_4dw union for reuse Sizhe Liu
2026-06-04 7:49 ` [PATCH 04/10] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-06-04 7:50 ` [PATCH 05/10] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
2026-06-04 7:50 ` [PATCH 06/10] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
2026-06-04 7:50 ` [PATCH 07/10] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
2026-06-04 7:50 ` [PATCH 08/10] perf hisi-ptt: Add parsing of supported message types Sizhe Liu
2026-06-04 7:50 ` [PATCH 09/10] perf hisi-ptt: Add field-level parsing for header DW2/DW3 Sizhe Liu
2026-06-04 7:50 ` [PATCH 10/10] perf hisi-ptt: Add decoder version compatibility Sizhe Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260604075005.2219785-3-liusizhe5@huawei.com \
--to=liusizhe5@huawei$(echo .)com \
--cc=acme@kernel$(echo .)org \
--cc=adrian.hunter@intel$(echo .)com \
--cc=alexander.shishkin@linux$(echo .)intel.com \
--cc=bhelgaas@google$(echo .)com \
--cc=corbet@lwn$(echo .)net \
--cc=fanghao11@huawei$(echo .)com \
--cc=gaozhihao6@h-partners$(echo .)com \
--cc=irogers@google$(echo .)com \
--cc=james.clark@linaro$(echo .)org \
--cc=jic23@kernel$(echo .)org \
--cc=john.g.garry@oracle$(echo .)com \
--cc=jolsa@kernel$(echo .)org \
--cc=leo.yan@linux$(echo .)dev \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-doc@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-pci@vger$(echo .)kernel.org \
--cc=linux-perf-users@vger$(echo .)kernel.org \
--cc=linuxarm@huawei$(echo .)com \
--cc=liyihang9@h-partners$(echo .)com \
--cc=mark.rutland@arm$(echo .)com \
--cc=mathieu.desnoyers@efficios$(echo .)com \
--cc=mhiramat@kernel$(echo .)org \
--cc=mike.leach@arm$(echo .)com \
--cc=mingo@redhat$(echo .)com \
--cc=namhyung@kernel$(echo .)org \
--cc=peterz@infradead$(echo .)org \
--cc=prime.zeng@hisilicon$(echo .)com \
--cc=rostedt@goodmis$(echo .)org \
--cc=shenyang39@huawei$(echo .)com \
--cc=skhan@linuxfoundation$(echo .)org \
--cc=wangyushan12@huawei$(echo .)com \
--cc=will@kernel$(echo .)org \
--cc=wuyifan50@huawei$(echo .)com \
--cc=yangyccccc@gmail$(echo .)com \
--cc=yuzhichengcheng@h-partners$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox