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 08/10] perf hisi-ptt: Add parsing of supported message types
Date: Thu, 4 Jun 2026 15:50:03 +0800 [thread overview]
Message-ID: <20260604075005.2219785-9-liusizhe5@huawei.com> (raw)
In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com>
Parse TLP message types from Header DW0 Format and Type fields for
both 4DW and 8DW formats, classifying packets into:
- MWr (Posted Memory Write)
- Msg (Posted Message)
- Atom (Non-Posted Atomic)
- IO (Non-Posted IO)
- CFG (Non-Posted Configuration)
- CPL (Completion)
Support for those message types depends on the hisi_ptt hardware.
The parsed message type is stored in pkt_buf->pkt_msg_type and will
be used by subsequent patches to select the correct field layout for
DW2 and DW3 printing.
Signed-off-by: Sizhe Liu <liusizhe5@huawei•com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 65 +++++++++++++++++++
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 12 ++++
tools/perf/util/hisi-ptt.c | 1 +
3 files changed, 78 insertions(+)
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
index 9ec84d398cc1..59ab8ec3a03d 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
@@ -78,6 +78,37 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = {
[HISI_PTT_4DW_HEAD3] = "Header DW3",
};
+static bool hisi_ptt_is_mwr_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0x2 || format == 0x3) && (type == 0);
+}
+
+static bool hisi_ptt_is_msg_tlp(uint32_t format, uint32_t type)
+{
+ return (format == 0x1 || format == 0x3) && ((type & 0x10) != 0);
+}
+
+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);
+}
+
union hisi_ptt_field_data {
/* Header DW0 for 4DW format */
struct {
@@ -90,9 +121,41 @@ union hisi_ptt_field_data {
uint32_t type : 5;
uint32_t format : 2;
} dw0_4dw;
+ /* Header DW0 for 8DW format */
+ struct {
+ uint32_t others : 24;
+ uint32_t type : 5;
+ uint32_t format : 3;
+ } dw0_8dw;
uint32_t value;
};
+static int hisi_ptt_parse_pkt_msg_type(union hisi_ptt_field_data dw,
+ enum hisi_ptt_pkt_type pkt_type)
+{
+ uint32_t format, type;
+
+ format = (pkt_type == HISI_PTT_4DW_PKT) ? dw.dw0_4dw.format :
+ dw.dw0_8dw.format;
+ type = (pkt_type == HISI_PTT_4DW_PKT) ? dw.dw0_4dw.type :
+ dw.dw0_8dw.type;
+
+ if (hisi_ptt_is_mwr_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_MWR;
+ else if (hisi_ptt_is_msg_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_MSG;
+ else if (hisi_ptt_is_atomic_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_ATOM;
+ else if (hisi_ptt_is_io_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_IO;
+ else if (hisi_ptt_is_cfg_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_CFG;
+ else if (hisi_ptt_is_cpl_tlp(format, type))
+ return HISI_PTT_PKT_TYPE_CPL;
+
+ return HISI_PTT_PKT_TYPE_UNKNOWN;
+}
+
static void hisi_ptt_print_raw_record(size_t offset, uint32_t value)
{
const char *color = PERF_COLOR_BLUE;
@@ -128,6 +191,8 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
union hisi_ptt_field_data dw;
dw.value = le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos));
+ pkt_buf->pkt_msg_type = hisi_ptt_parse_pkt_msg_type(dw,
+ pkt_buf->pkt_type);
hisi_ptt_print_raw_record(pkt_buf->pos, dw.value);
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 316f24f01068..3fdad34fe400 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
@@ -26,11 +26,23 @@ static int hisi_ptt_pkt_size[] = {
[HISI_PTT_8DW_PKT] = 32,
};
+enum hisi_ptt_pkt_msg_type {
+ HISI_PTT_PKT_TYPE_UNKNOWN, /* Types do not support analysis */
+ HISI_PTT_PKT_TYPE_MWR, /* P-(MemWr) */
+ HISI_PTT_PKT_TYPE_MSG, /* P-(Message) */
+ HISI_PTT_PKT_TYPE_ATOM, /* NP-(Atomic) */
+ HISI_PTT_PKT_TYPE_IO, /* NP-(IO) */
+ HISI_PTT_PKT_TYPE_CFG, /* NP-(CFG) */
+ HISI_PTT_PKT_TYPE_CPL, /* CPL-(CPL) */
+ HISI_PTT_PKT_TYPE_MAX
+};
+
struct hisi_ptt_pkt_buf {
const unsigned char *buf;
size_t pos;
size_t len;
enum hisi_ptt_pkt_type pkt_type;
+ enum hisi_ptt_pkt_msg_type pkt_msg_type;
};
int hisi_ptt_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf);
diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c
index 4efda3f3e5f9..e321f393601b 100644
--- a/tools/perf/util/hisi-ptt.c
+++ b/tools/perf/util/hisi-ptt.c
@@ -55,6 +55,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);
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
next prev parent reply other threads:[~2026-06-04 7:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 7:49 [PATCH 00/10] perf hisi-ptt: Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-06-04 7:49 ` [PATCH 01/10] perf hisi-ptt: Fix spelling and abbreviation errors Sizhe Liu
2026-06-04 7:49 ` [PATCH 02/10] perf hisi-ptt: Fix PTT trace TLP Header parsing Sizhe Liu
2026-06-04 7:49 ` [PATCH 03/10] perf hisi-ptt: Rename hisi_ptt_4dw union for reuse Sizhe Liu
2026-06-04 7:49 ` [PATCH 04/10] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-06-04 7:50 ` [PATCH 05/10] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
2026-06-04 7:50 ` [PATCH 06/10] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
2026-06-04 7:50 ` [PATCH 07/10] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
2026-06-04 7:50 ` Sizhe Liu [this message]
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-9-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