[PATCH v3 6/8] perf hisi-ptt: Add field-level parsing for header DW2/DW3
Sizhe Liu
liusizhe5 at huawei.com
Thu Sep 3 00:52:39 PDT 2026
Add field-level parsing of Header DW2 and DW3 of the TLP, separating
the layout for CFG TLPs and CPL TLPs. The message type parsed in the
previous patch is used to select the correct field layout.
DW2 fields are common to MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr
TLPs, parsed with FIELD_GET() against HISI_PTT_HEAD2_* masks.
DW3 fields have two layouts:
- CfgRd0/CfgWr0/CfgRd1/CfgWr1 use HISI_PTT_HEAD3_CFG_* masks
- Cpl/CplD/CplLk/CplDlk use HISI_PTT_HEAD3_CPL_* masks
HiSilicon PCIe trace device hardware is responsible for packet collection,
parsing, extraction and fills the corresponding fields with the required
positions. The packet decoder software will perform the parsing and
printing of fields filled by hardware.
Reviewed-by: Yushan Wang <wangyushan12 at huawei.com>
Signed-off-by: Sizhe Liu <liusizhe5 at huawei.com>
---
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 111 ++++++++++++++++--
.../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 39 ++++++
2 files changed, 141 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
index e63fe1534693..de1d4071e209 100644
--- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
+++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
@@ -197,6 +197,89 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
}
+static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ /* Currently, no distinction here for 4DW foramt and 8DW format */
+ hisi_ptt_print_pkt(pkt_buf,
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD1]);
+}
+
+static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *color = PERF_COLOR_BLUE;
+ uint32_t dw;
+
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw);
+
+ if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_MWR ||
+ pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_MSG ||
+ pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_ATOM ||
+ pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_IO)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Reserved",
+ FIELD_GET(HISI_PTT_HEAD2_RESERVED, dw),
+ "Request Segment",
+ FIELD_GET(HISI_PTT_HEAD2_REQ_SEG, dw),
+ "RSV", FIELD_GET(HISI_PTT_HEAD2_RSV, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD2_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD2_T, dw),
+ "Tag", FIELD_GET(HISI_PTT_HEAD2_TAG, dw),
+ "Header DW2",
+ FIELD_GET(HISI_PTT_HEAD2_HEADER_DW2, dw));
+ else
+ color_fprintf(stdout, color, " %s\n",
+ pkt_buf->pkt_type == HISI_PTT_4DW_PKT ?
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD2] :
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD2]);
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
+static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf)
+{
+ const char *color = PERF_COLOR_BLUE;
+ uint32_t dw;
+
+ dw = get_unaligned_le32(pkt_buf->buf + pkt_buf->pos);
+ hisi_ptt_print_raw_record(pkt_buf->pos, dw);
+
+ if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_CPL)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Destination Segment",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_DST_SEG, dw),
+ "Completer Segment",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_CPL_SEG, dw),
+ "DSV", FIELD_GET(HISI_PTT_HEAD3_CPL_DSV, dw),
+ "Reserved",
+ FIELD_GET(HISI_PTT_HEAD3_CPL_RESERVED, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_CPL_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_CPL_T, dw),
+ "Tag", FIELD_GET(HISI_PTT_HEAD3_CPL_TAG, dw));
+ else if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_CFG)
+ color_fprintf(stdout, color,
+ " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
+ "Reserved",
+ FIELD_GET(HISI_PTT_HEAD3_CFG_RESERVED, dw),
+ "Destination Segment",
+ FIELD_GET(HISI_PTT_HEAD3_CFG_DST_SEG, dw),
+ "DSV", FIELD_GET(HISI_PTT_HEAD3_CFG_DSV, dw),
+ "TV", FIELD_GET(HISI_PTT_HEAD3_CFG_TV, dw),
+ "T", FIELD_GET(HISI_PTT_HEAD3_CFG_T, dw),
+ "Tag", FIELD_GET(HISI_PTT_HEAD3_CFG_TAG, dw),
+ "Header DW3",
+ FIELD_GET(HISI_PTT_HEAD3_CFG_HEADER_DW3, dw));
+ else
+ color_fprintf(stdout, color, " %s\n",
+ pkt_buf->pkt_type == HISI_PTT_4DW_PKT ?
+ hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD3] :
+ hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD3]);
+
+ pkt_buf->pos += HISI_PTT_FIELD_LENGTH;
+}
+
static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
int i;
@@ -208,12 +291,24 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
continue;
}
- if (i == HISI_PTT_8DW_HEAD0) {
+ switch (i) {
+ case HISI_PTT_8DW_HEAD0:
hisi_ptt_print_head0(pkt_buf);
- continue;
+ break;
+ case HISI_PTT_8DW_HEAD1:
+ hisi_ptt_print_head1(pkt_buf);
+ break;
+ case HISI_PTT_8DW_HEAD2:
+ hisi_ptt_print_head2(pkt_buf);
+ break;
+ case HISI_PTT_8DW_HEAD3:
+ hisi_ptt_print_head3(pkt_buf);
+ break;
+ default:
+ hisi_ptt_print_pkt(pkt_buf,
+ hisi_ptt_8dw_pkt_field_name[i]);
+ break;
}
-
- hisi_ptt_print_pkt(pkt_buf, hisi_ptt_8dw_pkt_field_name[i]);
}
return hisi_ptt_pkt_size[HISI_PTT_8DW_PKT];
@@ -221,12 +316,10 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf)
{
- int i;
-
hisi_ptt_print_head0(pkt_buf);
-
- for (i = HISI_PTT_4DW_HEAD1; i < HISI_PTT_4DW_TYPE_MAX; i++)
- hisi_ptt_print_pkt(pkt_buf, hisi_ptt_4dw_pkt_field_name[i]);
+ hisi_ptt_print_head1(pkt_buf);
+ hisi_ptt_print_head2(pkt_buf);
+ hisi_ptt_print_head3(pkt_buf);
return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT];
}
diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h
index 436712e67a6f..61bf3b11a467 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
@@ -32,6 +32,45 @@
#define HISI_PTT_HEAD0_8DW_TYPE GENMASK_U32(28, 24)
#define HISI_PTT_HEAD0_8DW_FORMAT GENMASK_U32(31, 29)
+/* Header DW2 fields for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr TLPs
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|----------------|----|---|--|-----------|----------|
+ * fields [Reserved][Request Segment][RSV][TV][T][Tag<13:10>][Header DW2]
+ */
+#define HISI_PTT_HEAD2_HEADER_DW2 GENMASK_U32(15, 0)
+#define HISI_PTT_HEAD2_TAG GENMASK_U32(19, 16)
+#define HISI_PTT_HEAD2_T BIT_U32(20)
+#define HISI_PTT_HEAD2_TV BIT_U32(21)
+#define HISI_PTT_HEAD2_RSV BIT_U32(22)
+#define HISI_PTT_HEAD2_REQ_SEG GENMASK_U32(30, 23)
+#define HISI_PTT_HEAD2_RESERVED BIT_U32(31)
+
+/* Header DW3 fields for CfgRd0/CfgWr0/CfgRd1/CfgWr1 TLPs
+ * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ]
+ * |---------|--------------------|----|---|--|-----------|----------|
+ * fields [Reserved][Destination Segment][DSV][TV][T][Tag<13:10>][Header DW3]
+ */
+#define HISI_PTT_HEAD3_CFG_HEADER_DW3 GENMASK_U32(15, 0)
+#define HISI_PTT_HEAD3_CFG_TAG GENMASK_U32(19, 16)
+#define HISI_PTT_HEAD3_CFG_T BIT_U32(20)
+#define HISI_PTT_HEAD3_CFG_TV BIT_U32(21)
+#define HISI_PTT_HEAD3_CFG_DSV BIT_U32(22)
+#define HISI_PTT_HEAD3_CFG_DST_SEG GENMASK_U32(30, 23)
+#define HISI_PTT_HEAD3_CFG_RESERVED BIT_U32(31)
+
+/* Header DW3 fields for Cpl/CplD/CplLk/CplDlk TLPs
+ * bits [ 31:24 ][ 23:16 ][15][ 14:6 ][5][4][ 3:0 ]
+ * |--------------------|------------------|----|---------|--|---|----------|
+ * fields [Destination Segment][Completer Segment][DSV][Reserved][TV][T][Tag<13:10>]
+ */
+#define HISI_PTT_HEAD3_CPL_TAG GENMASK_U32(3, 0)
+#define HISI_PTT_HEAD3_CPL_T BIT_U32(4)
+#define HISI_PTT_HEAD3_CPL_TV BIT_U32(5)
+#define HISI_PTT_HEAD3_CPL_RESERVED GENMASK_U32(14, 6)
+#define HISI_PTT_HEAD3_CPL_DSV BIT_U32(15)
+#define HISI_PTT_HEAD3_CPL_CPL_SEG GENMASK_U32(23, 16)
+#define HISI_PTT_HEAD3_CPL_DST_SEG GENMASK_U32(31, 24)
+
enum hisi_ptt_pkt_type {
HISI_PTT_4DW_PKT,
HISI_PTT_8DW_PKT,
--
2.33.0
More information about the linux-arm-kernel
mailing list