From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D009F28C5B1; Thu, 3 Sep 2026 07:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421975; cv=none; b=ModtlhbRAV9BXlDYjpEi/9crk8Av7zwgAgNXUeOD0cRUbxR8TGHrktYUy9ozv81YVdAyKFaXF281s5+MkMJQ8SJpiOotvL+uTMhh9WYSlKbR+9NWaxC6wN4JrkL2/pWE7DYeQDFy2AuU6rsY+cs/0Joa7jQ44OCb0MeCT0EGF1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421975; c=relaxed/simple; bh=ZkSa5qlS66ITQsGD0bm2TaiLYkgiuBXR4HO+CvEheds=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i4NK/dCZ1oMTcsS7i06wfoQVpYEpXP2EoLMmNOS7TzyrVGSmYVxvg2XBG0pjzE6EnNMpOvLGKjzcIBVAZJ5QT8DnQ5D866RnvZy84cP0EOjFeZhr5FjlEU6VTr3EQ5y8t9bcquYtckLVg7dECiGIqmJnhUZRsbv9ykIu/mk1ImY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=N9HRA88A; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="N9HRA88A" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=16GO9nI+z9h3lP3iWDNg0HC9DHfO6KEMTyKs16sIM3o=; b=N9HRA88Ako3kNVoQrRVKt31rjfcmDS4XKLKCK5pk15NcIehh5pqQ+xDUhWv6ar0CghtyKACML wyML2sAgs9fx+IfQRva95aYsE0tnYw7A+UAaTBK0wD9AdgohrPMYEeuGdLG79eZolv/PBRTY6iO qUMED4xvPb90DsYUt/I1DKQ= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPb2Bgfz1prlh; Thu, 3 Sep 2026 15:41:55 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 8AE9540575; Thu, 3 Sep 2026 15:52:47 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:45 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 1/8] perf hisi-ptt: Abstract trace data buf and offset Date: Thu, 3 Sep 2026 15:52:34 +0800 Message-ID: <20260903075241.1445338-2-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Sizhe Liu --- .../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/tool= s/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[]= =3D { [HISI_PTT_4DW_HEAD3] =3D "Header DW3", }; =20 -static void hisi_ptt_print_pkt(const unsigned char *buf, int pos, const ch= ar *desc) +static void hisi_ptt_print_pkt(struct hisi_ptt_pkt_buf *pkt_buf, + const char *desc) { const char *color =3D PERF_COLOR_BLUE; uint8_t byte; uint32_t dw; int i; =20 - dw =3D get_unaligned_le32(buf + pos); + dw =3D 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 =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { byte =3D (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 =3D 0; i < HISI_PTT_MAX_SPACE_LEN; i++) color_fprintf(stdout, color, " "); color_fprintf(stdout, color, " %s\n", desc); + pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } =20 -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; =20 for (i =3D 0; i < HISI_PTT_8DW_TYPE_MAX; i++) { /* Do not show 8DW check field and reserved fields */ if (i =3D=3D HISI_PTT_8DW_CHK_AND_RSV0 || i =3D=3D HISI_PTT_8DW_RSV1) { - pos +=3D HISI_PTT_FIELD_LENGTH; + pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; continue; } =20 - hisi_ptt_print_pkt(buf, pos, hisi_ptt_8dw_pkt_field_name[i]); - pos +=3D HISI_PTT_FIELD_LENGTH; + hisi_ptt_print_pkt(pkt_buf, hisi_ptt_8dw_pkt_field_name[i]); } =20 return hisi_ptt_pkt_size[HISI_PTT_8DW_PKT]; } =20 -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 =3D PERF_COLOR_BLUE; uint8_t byte; uint32_t dw; int i; =20 - dw =3D get_unaligned_le32(buf + pos); + dw =3D 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 =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { byte =3D (dw >> (24 - i * 8)) & 0xFF; color_fprintf(stdout, color, "%02x ", byte); @@ -139,27 +140,26 @@ static void hisi_ptt_4dw_print_dw0(const unsigned cha= r *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 +=3D HISI_PTT_FIELD_LENGTH; } =20 -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; =20 - hisi_ptt_4dw_print_dw0(buf, pos); - pos +=3D HISI_PTT_FIELD_LENGTH; + hisi_ptt_4dw_print_dw0(pkt_buf); =20 - for (i =3D 0; i < HISI_PTT_4DW_TYPE_MAX; i++) { - hisi_ptt_print_pkt(buf, pos, hisi_ptt_4dw_pkt_field_name[i]); - pos +=3D HISI_PTT_FIELD_LENGTH; - } + for (i =3D 0; i < HISI_PTT_4DW_TYPE_MAX; i++) + hisi_ptt_print_pkt(pkt_buf, hisi_ptt_4dw_pkt_field_name[i]); =20 return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT]; } =20 -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 =3D=3D HISI_PTT_8DW_PKT) - return hisi_ptt_8dw_pkt_desc(buf, pos); + if (pkt_buf->pkt_type =3D=3D HISI_PTT_8DW_PKT) + return hisi_ptt_8dw_pkt_desc(pkt_buf); =20 - 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/tool= s/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[] =3D { [HISI_PTT_8DW_PKT] =3D 32, }; =20 -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); =20 #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 =3D PERF_COLOR_BLUE; - enum hisi_ptt_pkt_type type; - size_t pos =3D 0; - int pkt_len; + struct hisi_ptt_pkt_buf pkt_buf; =20 - type =3D hisi_ptt_check_packet_type(buf, len); - len =3D round_down(len, hisi_ptt_pkt_size[type]); + pkt_buf.buf =3D buf; + pkt_buf.pos =3D 0; + pkt_buf.pkt_type =3D hisi_ptt_check_packet_type(buf, len); + pkt_buf.len =3D 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); =20 - while (len > 0) { - pkt_len =3D 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 +=3D pkt_len; - len -=3D pkt_len; } } =20 --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40B1325B099; Thu, 3 Sep 2026 07:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421975; cv=none; b=cPexNjHOSaI5qgrMNIVnWIO2J9a2d66gJ6wWiPwQQSBPXD5ek8nZMHnLJI25oNKgt8JlPWdbUtSxxpIcDvjTBGWYhGpS7mfaAUNZPSK7d+NH5lP0NG7fdsLKHpKbFBpTirjOyub+lTgu+j2Vls8Y6xcY6jXaVn8tJ9ByS4a+jqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421975; c=relaxed/simple; bh=uv31mMGJY8917i0D41i+PSbwTCNxtolCmItMY7GqkH0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=umYcuKiO53QybyLvOIzYQKSt3xxnWwuLBb2wQ4x9kuS+d5fdMxnuw+MA/k420L/GpBhlRzH0C20yPtiEPHSutBAjt//zm//sEHDDVHeJhLVqU8E98xFmGcWZchPDkZBseMVQrRvk5VwYcrYsn8fERE8P2vtIKOLBUaAfP5WZuZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=KWuF6IC6; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="KWuF6IC6" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=SHFtsegYkSXAAQ6VLTBIGRfXAcm81uMjTTor0MXHuTI=; b=KWuF6IC6bGKi3ranAbI8gv4Ii8gUY2i6kQGwdMJTdCvr84XKLmPVUEiqnlsqQezcuJF0YoE9V n+IXuXFtWfSPpwbhu1sHzejM/vwmpPiFHKShH/JP3LT0DdkhFBdE+eZ0at7vhrFHa4xhAltw2w9 zzRxS6N5Gufcj4+3IEI7YS8= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPB0Gy3z12LDV; Thu, 3 Sep 2026 15:41:34 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id BF95B40591; Thu, 3 Sep 2026 15:52:49 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:47 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Date: Thu, 3 Sep 2026 15:52:35 +0800 Message-ID: <20260903075241.1445338-3-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Sizhe Liu --- .../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/tool= s/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 { }; =20 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 { }; =20 static const char * const hisi_ptt_8dw_pkt_field_name[] =3D { - [HISI_PTT_8DW_PREFIX] =3D "Prefix", - [HISI_PTT_8DW_HEAD0] =3D "Header DW0", - [HISI_PTT_8DW_HEAD1] =3D "Header DW1", - [HISI_PTT_8DW_HEAD2] =3D "Header DW2", - [HISI_PTT_8DW_HEAD3] =3D "Header DW3", - [HISI_PTT_8DW_TIME] =3D "Time" + [HISI_PTT_8DW_CHK_AND_RSV0] =3D "CHK & RSV0", + [HISI_PTT_8DW_PREFIX] =3D "Prefix", + [HISI_PTT_8DW_HEAD0] =3D "Header DW0", + [HISI_PTT_8DW_HEAD1] =3D "Header DW1", + [HISI_PTT_8DW_HEAD2] =3D "Header DW2", + [HISI_PTT_8DW_HEAD3] =3D "Header DW3", + [HISI_PTT_8DW_RSV1] =3D "RSV1", + [HISI_PTT_8DW_TIME] =3D "Time" }; =20 static const char * const hisi_ptt_4dw_pkt_field_name[] =3D { + [HISI_PTT_4DW_HEAD0] =3D "Header DW0", [HISI_PTT_4DW_HEAD1] =3D "Header DW1", [HISI_PTT_4DW_HEAD2] =3D "Header DW2", [HISI_PTT_4DW_HEAD3] =3D "Header DW3", @@ -100,7 +104,7 @@ static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_bu= f *pkt_buf) { int i; =20 - for (i =3D 0; i < HISI_PTT_8DW_TYPE_MAX; i++) { + for (i =3D HISI_PTT_8DW_CHK_AND_RSV0; i < HISI_PTT_8DW_TYPE_MAX; i++) { /* Do not show 8DW check field and reserved fields */ if (i =3D=3D HISI_PTT_8DW_CHK_AND_RSV0 || i =3D=3D HISI_PTT_8DW_RSV1) { pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; @@ -150,7 +154,7 @@ static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_bu= f *pkt_buf) =20 hisi_ptt_4dw_print_dw0(pkt_buf); =20 - for (i =3D 0; i < HISI_PTT_4DW_TYPE_MAX; i++) + for (i =3D HISI_PTT_4DW_HEAD1; i < HISI_PTT_4DW_TYPE_MAX; i++) hisi_ptt_print_pkt(pkt_buf, hisi_ptt_4dw_pkt_field_name[i]); =20 return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT]; --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DD5062809; Thu, 3 Sep 2026 07:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421977; cv=none; b=nJd+m+FyBy8a15ddLLc4QHvQsrAANeuXWnHTel01zY5Py+VHM+xV4p272lz/DiC3arQKFbCs9W39EMyHXzNtG2PT+wdERwouYE2k1iMt/eBK7O449Is2tzcD/PqSyW1sFw00u/00y7FJLy40Y1aN6Nw3qdHrU66/Jhr83CranGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421977; c=relaxed/simple; bh=11TxVI+3RBj+EqHgRjR2LbaLhcvV0cslORERYKWeuco=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f6d5KJtjEulCR3x2Eav5CH5avXy1zh5ezJ2b6w2IvhBu8xx5cOcdaVVhG6GfBrgcR/4EyGM1fn24KA91juC6pIjvtdAdZw7tBG8WRNUJ092XQr3WfXZo4hugiGfyaSYeuiCqECBz+/fU++YkSbglQk/zs5SHBcy5AcXRO4TSSQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=QPcdzo9L; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="QPcdzo9L" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=CaouMrHf0sBpiH7oiFC52Kf32tgj7gpdzB/pLuk6TXE=; b=QPcdzo9LzezfooH0eCR+FqKx6wKR0nt7K5LkOl6xwr4WTy+eevZBB22JIctC741u6HVe9vl8P 0BKoN+OTu9GnhlXHE8vBlbMbctmmEt6UObCKvVNwve2k+xyHTL55d7A+FecuTUHTGE6yWC8JfOU SKXE/X7TQMyQm0SsEeFfWAo= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPm4ZBSzcbQ9; Thu, 3 Sep 2026 15:42:04 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id EE07240575; Thu, 3 Sep 2026 15:52:51 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:49 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 3/8] perf hisi-ptt: Extract the raw data printing part Date: Thu, 3 Sep 2026 15:52:36 +0800 Message-ID: <20260903075241.1445338-4-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Sizhe Liu --- .../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/tool= s/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[]= =3D { [HISI_PTT_4DW_HEAD3] =3D "Header DW3", }; =20 -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 =3D PERF_COLOR_BLUE; uint8_t byte; - uint32_t dw; int i; =20 - dw =3D 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 =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { - byte =3D (dw >> (24 - i * 8)) & 0xFF; + byte =3D (value >> (24 - i * 8)) & 0xFF; color_fprintf(stdout, color, "%02x ", byte); } for (i =3D 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 =3D PERF_COLOR_BLUE; + uint32_t value; + + value =3D 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 +=3D 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 =3D PERF_COLOR_BLUE; - uint8_t byte; uint32_t dw; - int i; =20 dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); - printf("."); - color_fprintf(stdout, color, " %08zx: ", pkt_buf->pos); - for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { - byte =3D (dw >> (24 - i * 8)) & 0xFF; - color_fprintf(stdout, color, "%02x ", byte); - } - for (i =3D 0; i < HISI_PTT_MAX_SPACE_LEN; i++) - color_fprintf(stdout, color, " "); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); =20 color_fprintf(stdout, color, " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB51D397AE4; Thu, 3 Sep 2026 07:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421978; cv=none; b=jigOi/35qmjlAssybokRYsBscNQ0wMMiSliq2xbcboP3gyZ+pmU3tQXgZ/ykVcoQhwgWYGvSndhHGZXN/QEJh1piwbefcteWHv6ab0VMopPL8kC+RW7KhdAul0OvOV+8vTQ+WWYjNNZ4XsOb5tiaP0x6LZtERUdBfv2Xq+mbUfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421978; c=relaxed/simple; bh=szcD0O0Lfg6pYgcK/czU3XzUQZ3ONYu2wuySJYZ2NP8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qkCZuv777tp3+mn2bmUwCB40qj6Y2mhic5xMx0Rp+QptckirV/NJURcWd3S24NxH57aTosYNxmviBPPSmRrSV61+LRwkgfkb5iVLWTiB41zXhp4JiLl/djiwQPtCsS4w9SLzpS20Nczd03T7DUWBVoNznx1bM/ofMYjE9tzPj4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=tgURI+w0; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="tgURI+w0" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=fQMRWjJVk821g2t06PS1R48o+Gaj+3LX6g+X1hR1mf4=; b=tgURI+w0BRHAgHaFEqonxW3WaXwFvR8Nr4fP1kW36eaVjpi2Z++0O68vEaNmNsnSgSN8fDvGG fFnYzTp9ffm6eJmJrDlkl/CjZlOsihUCbfi/cDDB7f588uCXwhDG9OLXsUFwmGT83BVB/tDjWgc xYTUr6tI2nk1MTIu/HT/aX0= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPp5zWMzcbQq; Thu, 3 Sep 2026 15:42:06 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 344A44057F; Thu, 3 Sep 2026 15:52:54 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:51 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Date: Thu, 3 Sep 2026 15:52:37 +0800 Message-ID: <20260903075241.1445338-5-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Sizhe Liu --- .../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/tool= s/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 +=3D HISI_PTT_FIELD_LENGTH; } =20 +static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf) +{ + const char *color =3D PERF_COLOR_BLUE; + uint32_t dw; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + if (pkt_buf->pkt_type =3D=3D 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 +=3D 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; } =20 + if (i =3D=3D HISI_PTT_8DW_HEAD0) { + hisi_ptt_print_head0(pkt_buf); + continue; + } + hisi_ptt_print_pkt(pkt_buf, hisi_ptt_8dw_pkt_field_name[i]); } =20 return hisi_ptt_pkt_size[HISI_PTT_8DW_PKT]; } =20 -static void hisi_ptt_4dw_print_dw0(struct hisi_ptt_pkt_buf *pkt_buf) -{ - const char *color =3D PERF_COLOR_BLUE; - uint32_t dw; - - dw =3D 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 +=3D HISI_PTT_FIELD_LENGTH; -} - static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf) { int i; =20 - hisi_ptt_4dw_print_dw0(pkt_buf); + hisi_ptt_print_head0(pkt_buf); =20 for (i =3D HISI_PTT_4DW_HEAD1; i < HISI_PTT_4DW_TYPE_MAX; i++) hisi_ptt_print_pkt(pkt_buf, hisi_ptt_4dw_pkt_field_name[i]); --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19FBC40803B; Thu, 3 Sep 2026 07:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421981; cv=none; b=FFC1SgGkzvxHEV25RnPnE/m8a6u2MZB+ZLQA+kOMOIp4BilokpNeIKJ5WVRIyt2VF5erfpJXmqmnB4QsA1Yj1lmsKLN2I+PA/GBn9vwpf6/WtMuDWVZSf8WNWxRdhtMgP5X9uCdKiNFSBstLahrvtItIgYsmXWm7GwarjDekJss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421981; c=relaxed/simple; bh=4qhpdP5/0AeU3FQ+N4EC+C3DtRstOu8wyY++r7xcsdk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y5suQXZ9X3N0mSChS3CSeIp3dorQlvM4OJaAK/vt/mf92N3tATodbd1WVe3mvUQne5ZXPSMVVI7Ao1Iy+TCdipdNy95RiBYc2TVI+xV70v4U/iocQG7dTvam/ZgRBEEio+NPr8MB2aKnd/wHdGaM95ywy9fWTbvlsZDgwT2fQZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=jBwqgwJt; arc=none smtp.client-ip=113.46.200.224 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="jBwqgwJt" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=nqr9TBBigcc7SJqP6XB+xbJPVqGbbMmN+1rNcOTnL2A=; b=jBwqgwJtVfe9inJ4dmzuHrOdNq6IDZsBgiO9dMw3efucJ2H5vj8KySaCBtWt9RGQvy3Y0pako EsT8jn896psc/jT+UDtl+ozNuE64AVZf5efstapAGVFiiH2awjXOY3eRsWNdBHl2l6Qntm/PYol b8XP5tPAO837O9Kqlq/tb+U= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPp3k8sz1cyR3; Thu, 3 Sep 2026 15:42:06 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 66FF44055B; Thu, 3 Sep 2026 15:52:56 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:53 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 5/8] perf hisi-ptt: Add parsing of supported message types Date: Thu, 3 Sep 2026 15:52:38 +0800 Message-ID: <20260903075241.1445338-6-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" Classify TLP messages by Header DW0 Format field and Type field for both 4DW and 8DW formats, according to PCIe r6.4 sec 2.2.1.1 & 2.2.1.2. Parsing packets into: - MWr (Posted Memory Write request) - Msg (Posted Message request) - Atom (Non-Posted Atomic request) - IO (Non-Posted IO request) - CFG (Non-Posted Configuration request) - CPL (Completion request) The parsed message type is stored in pkt_buf->pkt_msg_type and will be used by subsequent patches to select the correct field layout for DW2 and DW3 printing. Reviewed-by: Yushan Wang Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 62 +++++++++++++++++++ .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 17 +++++ tools/perf/util/hisi-ptt.c | 1 + 3 files changed, 80 insertions(+) diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c b/tool= s/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c index 00bd9309df68..e63fe1534693 100644 --- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c +++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c @@ -79,6 +79,66 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = =3D { [HISI_PTT_4DW_HEAD3] =3D "Header DW3", }; =20 +/* TLP message parsers below according to PCIe r6.4 sec 2.2.1.1 & 2.2.1.2 = */ +static bool hisi_ptt_is_mwr_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0x2 || format =3D=3D 0x3) && (type =3D=3D 0); +} + +static bool hisi_ptt_is_msg_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0x1 || format =3D=3D 0x3) && ((type & 0x18) =3D=3D = 0x10); +} + +static bool hisi_ptt_is_io_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0 || format =3D=3D 0x2) && (type =3D=3D 0x2); +} + +static bool hisi_ptt_is_atomic_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0x2 || format =3D=3D 0x3) && + (type =3D=3D 0xc || type =3D=3D 0xd || type =3D=3D 0xe); +} + +static bool hisi_ptt_is_cfg_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0 || format =3D=3D 0x2) && (type =3D=3D 0x4 || type= =3D=3D 0x5); +} + +static bool hisi_ptt_is_cpl_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0 || format =3D=3D 0x2) && (type =3D=3D 0xa || typ= e =3D=3D 0xb); +} + +static int hisi_ptt_parse_pkt_msg_type(uint32_t dw, + enum hisi_ptt_pkt_type pkt_type) +{ + uint32_t format, type; + + format =3D (pkt_type =3D=3D HISI_PTT_4DW_PKT) ? + FIELD_GET(HISI_PTT_HEAD0_4DW_FORMAT, dw) : + FIELD_GET(HISI_PTT_HEAD0_8DW_FORMAT, dw); + type =3D (pkt_type =3D=3D HISI_PTT_4DW_PKT) ? + FIELD_GET(HISI_PTT_HEAD0_4DW_TYPE, dw) : + FIELD_GET(HISI_PTT_HEAD0_8DW_TYPE, dw); + + if (hisi_ptt_is_mwr_tlp(format, type)) + return HISI_PTT_PKT_TYPE_MWR; + else if (hisi_ptt_is_msg_tlp(format, type)) + return HISI_PTT_PKT_TYPE_MSG; + else if (hisi_ptt_is_atomic_tlp(format, type)) + return HISI_PTT_PKT_TYPE_ATOM; + else if (hisi_ptt_is_io_tlp(format, type)) + return HISI_PTT_PKT_TYPE_IO; + else if (hisi_ptt_is_cfg_tlp(format, type)) + return HISI_PTT_PKT_TYPE_CFG; + else if (hisi_ptt_is_cpl_tlp(format, type)) + return HISI_PTT_PKT_TYPE_CPL; + + return HISI_PTT_PKT_TYPE_UNKNOWN; +} + static void hisi_ptt_print_raw_record(size_t offset, uint32_t value) { const char *color =3D PERF_COLOR_BLUE; @@ -114,6 +174,8 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_bu= f *pkt_buf) uint32_t dw; =20 dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + pkt_buf->pkt_msg_type =3D hisi_ptt_parse_pkt_msg_type(dw, + pkt_buf->pkt_type); hisi_ptt_print_raw_record(pkt_buf->pos, dw); =20 if (pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT) diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tool= s/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h index 6747878b030e..436712e67a6f 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,6 +7,7 @@ #ifndef INCLUDE__HISI_PTT_PKT_DECODER_H__ #define INCLUDE__HISI_PTT_PKT_DECODER_H__ =20 +#include #include #include #include @@ -27,6 +28,10 @@ #define HISI_PTT_HEAD0_4DW_TYPE GENMASK_U32(29, 25) #define HISI_PTT_HEAD0_4DW_FORMAT GENMASK_U32(31, 30) =20 +/* 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 +43,23 @@ static int hisi_ptt_pkt_size[] =3D { [HISI_PTT_8DW_PKT] =3D 32, }; =20 +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; }; =20 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_un= used, pkt_buf.pos =3D 0; pkt_buf.pkt_type =3D hisi_ptt_check_packet_type(buf, len); pkt_buf.len =3D round_down(len, hisi_ptt_pkt_size[pkt_buf.pkt_type]); + pkt_buf.pkt_msg_type =3D HISI_PTT_PKT_TYPE_UNKNOWN; color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n", pkt_buf.len); =20 --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59280366042; Thu, 3 Sep 2026 07:53:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421990; cv=none; b=iwuH366EwLU6M5SXzOjRraVXBF7eNnsQXu5IPyTypXpnVcAo2O1xW0O+r/2lNzBloj3bTrf2jxJ2XLuTiwTbJ5z+OvZq75cjqoE76QDlSfWC47RIIpGk7q96MzpXYJXjqXxoFp+E4JVnbSmoFhvxLq8e83xsKZPuOZSpumeBypU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421990; c=relaxed/simple; bh=uB2voWJWWwqcwEfU4mBDv4gB2UDIvsJNQF5p2Fb+13c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ENK542OQdEyyHjPrZ+1PmW9aG54mXdD7Uxl05pygLGozUqrr4eBkv3SD7uU5uesqHfIhNH6JE9usIPsrCGVRVcq9F3I19ceWuf/uWdBKCGjCog6xOBnk/i1sKb/qE1AcrOihPTcvq/7AuvUtJpCHYEtYJspBaoYiJzXkMdSFSIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=y9W2izZZ; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="y9W2izZZ" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=XltDT7kt/cIBZMrmqOCKCSZiG6zYBIDIlmJb3RAiwnw=; b=y9W2izZZRALfN04PVSBoy60UUxghLoFMg274T7qcSPB364qIXa6f6M5CqTjzcMfiQYrKTiDt+ qKfC9YlBAEj+3GmLMgNIRRrHAYFIvpG3TApCF6lvfZDVgOIYP0XZpTl4uFBoNsz0xPui9fLkj3O RLWDqH67JYq6tm1nKzHpe0c= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPD24j6zpT0s; Thu, 3 Sep 2026 15:41:36 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id AB03440538; Thu, 3 Sep 2026 15:52:58 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:56 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 6/8] perf hisi-ptt: Add field-level parsing for header DW2/DW3 Date: Thu, 3 Sep 2026 15:52:39 +0800 Message-ID: <20260903075241.1445338-7-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Sizhe Liu --- .../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/tool= s/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_b= uf *pkt_buf) pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } =20 +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 =3D PERF_COLOR_BLUE; + uint32_t dw; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + if (pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_MWR || + pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_MSG || + pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_ATOM || + pkt_buf->pkt_msg_type =3D=3D 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 =3D=3D 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 +=3D HISI_PTT_FIELD_LENGTH; +} + +static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf) +{ + const char *color =3D PERF_COLOR_BLUE; + uint32_t dw; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + if (pkt_buf->pkt_msg_type =3D=3D 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 =3D=3D 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 =3D=3D 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 +=3D 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; } =20 - if (i =3D=3D 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]); } =20 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) =20 static int hisi_ptt_4dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf) { - int i; - hisi_ptt_print_head0(pkt_buf); - - for (i =3D 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); =20 return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT]; } diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tool= s/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) =20 +/* 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, --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BAB138AC96; Thu, 3 Sep 2026 07:53:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421995; cv=none; b=T0YXCl/Ij+buydUHEPEmNRs3QJGT1465PtixFeZnAfujSIoYdi8ab8Qc5S6qlBJz7+/v9Js+8XCUvPVOFgqt87dQXcA/MzaOD65tBYHOYlWcTXkhJ3x6CF7RQD8PXrnByREdP54FVUalzNKcckpxfibVLsOvuqEPkOcS8w156Zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421995; c=relaxed/simple; bh=X/4JlpWNOCeR4BuVv8FHlzWf+j7va+TrxaWsBdcn39U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RSXrBSpW182qxb2o2OVs4ILfaP1yp57Ld6JdAxbats3dMnnCc8AFGDph+GExveQ91M8UGWS4mbZeCAfwiIO7j5z0q7ftBAC2Xl3MArFALmdBu4ffm7sKdFBnbXspiK1ZSCqgGIPabvsubM2RnT/6gGVaU1u4+mayBnBGwkv+9n8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=cQ0MRwE6; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="cQ0MRwE6" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=s/pD42JPz9w41he7m9JGqlBsNJR67TIhtx7nAJkGXi8=; b=cQ0MRwE6o87Q8lmYCxmGVUzCYVcADUssmfi0SfXCLNz/34M6tuTT0qaJrOyAJ1K5OkvfXRFU1 KRkyg73VPCjJhGcuu3V69BGcq49UKQIFJz4dovwdL94wzYWgK1F7cpLNS+ABugnXZVRYzkXzFIk oEkTmtcfhvRCikM7mOBHOJ8= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPt2JmSzLlTg; Thu, 3 Sep 2026 15:42:10 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id D781340565; Thu, 3 Sep 2026 15:53:00 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:52:58 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Date: Thu, 3 Sep 2026 15:52:40 +0800 Message-ID: <20260903075241.1445338-8-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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=3D0 (default, compatibility mode): the driver sets bit[8] of HISI_PTT_TRACE_CTRL so the hardware traces the data in compatibility mode. - pattern=3D1: 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]=3D1 selects the legacy format, bit[8]=3D0 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 Signed-off-by: Sizhe Liu --- Documentation/trace/hisi-ptt.rst | 25 +++++++++++++++++++++++-- drivers/hwtracing/ptt/hisi_ptt.c | 25 ++++++++++++++++++++++++- drivers/hwtracing/ptt/hisi_ptt.h | 4 ++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Documentation/trace/hisi-ptt.rst b/Documentation/trace/hisi-pt= t.rst index f6a2655f99e5..c95eaa12f4d3 100644 --- a/Documentation/trace/hisi-ptt.rst +++ b/Documentation/trace/hisi-ptt.rst @@ -255,7 +255,28 @@ directly from the TLP header. DW2 [ Header DW2 ] DW3 [ Header DW3 ] =20 -5. Memory Management +5. Trace pattern +----------------- + +You can control whether the trace is taken with the new version of the +TLP header format by specifying the `pattern` parameter. The default +value is 0, which means the legacy format is used for backward +compatibility. The parameter value is 4 bit and bit[3:1] are currently +reserved for extension. Current supported values are shown below: + +- 4'b0000: legacy trace format + DW2 and DW3 are printed with generic field names only, and + no message-type-basedfield decoding. +- 4'b0001: trace format v1 + DW2 and DW3 are decoded according to the TLP message type (MWr, + Msg, Atomic, IO, CPL, Cfg) with detailed field names. It is recommende= d to + use trace format v1 when the current PCIe link generation is higher th= an + 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 -------------------- =20 The traced TLP headers will be written to the memory allocated @@ -274,7 +295,7 @@ will commit the AUX buffer first and then apply for a n= ew 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. =20 -6. Decoding +7. Decoding ----------- =20 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 |=3D FIELD_PREP(HISI_PTT_TRACE_CTRL_TARGET_SEL, hisi_ptt->trace_ctrl.= filter); if (!hisi_ptt->trace_ctrl.is_port) val |=3D HISI_PTT_TRACE_CTRL_FILTER_MODE; + if (!ctrl->pattern) + val |=3D HISI_PTT_TRACE_CTRL_PATTERN; + else + val &=3D ~HISI_PTT_TRACE_CTRL_PATTERN; =20 ctrl->started =3D true; =20 @@ -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"); =20 static struct attribute *hisi_ptt_pmu_format_attrs[] =3D { &format_attr_filter.attr, &format_attr_direction.attr, &format_attr_type.attr, &format_attr_format.attr, + &format_attr_pattern.attr, NULL }; =20 @@ -941,6 +947,15 @@ static int hisi_ptt_trace_valid_format(u32 val) return -EINVAL; } =20 +static int hisi_ptt_trace_valid_pattern(u32 val) +{ + /* Currently only bit0 is used, bit[3:1] are reserved for extension. */ + if (val <=3D 1) + return 0; + + return -EINVAL; +} + static int hisi_ptt_trace_valid_filter(struct hisi_ptt *hisi_ptt, u64 conf= ig) { unsigned long val, port_mask =3D hisi_ptt->port_mask; @@ -991,6 +1006,9 @@ static void hisi_ptt_pmu_init_configs(struct hisi_ptt = *hisi_ptt, struct perf_eve =20 val =3D FIELD_GET(HISI_PTT_PMU_FORMAT_MASK, event->attr.config); ctrl->format =3D val; + + val =3D FIELD_GET(HISI_PTT_PMU_PATTERN_MASK, event->attr.config); + ctrl->pattern =3D val; } =20 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; =20 val =3D FIELD_GET(HISI_PTT_PMU_FORMAT_MASK, event->attr.config); - return hisi_ptt_trace_valid_format(val); + ret =3D hisi_ptt_trace_valid_format(val); + if (ret < 0) + return ret; + + val =3D FIELD_GET(HISI_PTT_PMU_PATTERN_MASK, event->attr.config); + return hisi_ptt_trace_valid_pattern(val); } =20 static void *hisi_ptt_pmu_setup_aux(struct perf_event *event, void **pages, diff --git a/drivers/hwtracing/ptt/hisi_ptt.h b/drivers/hwtracing/ptt/hisi_= ptt.h index 46030aa88081..584f65ba1e32 100644 --- a/drivers/hwtracing/ptt/hisi_ptt.h +++ b/drivers/hwtracing/ptt/hisi_ptt.h @@ -41,6 +41,7 @@ #define HISI_PTT_TRACE_CTRL_RST BIT(1) #define HISI_PTT_TRACE_CTRL_RXTX_SEL GENMASK(3, 2) #define HISI_PTT_TRACE_CTRL_TYPE_SEL GENMASK(7, 4) +#define HISI_PTT_TRACE_CTRL_PATTERN BIT(8) #define HISI_PTT_TRACE_CTRL_DATA_FORMAT BIT(14) #define HISI_PTT_TRACE_CTRL_FILTER_MODE BIT(15) #define HISI_PTT_TRACE_CTRL_TARGET_SEL GENMASK(31, 16) @@ -89,6 +90,7 @@ #define HISI_PTT_PMU_DIRECTION_MASK GENMASK(23, 20) #define HISI_PTT_PMU_TYPE_MASK GENMASK(31, 24) #define HISI_PTT_PMU_FORMAT_MASK GENMASK(35, 32) +#define HISI_PTT_PMU_PATTERN_MASK GENMASK(39, 36) =20 /** * struct hisi_ptt_tune_desc - Describe tune event for PTT tune @@ -127,6 +129,7 @@ struct hisi_ptt_dma_buffer { * @filter: filter value for tracing the TLP headers * @format: format of the TLP headers to trace * @type: type of the TLP headers to trace + * @pattern: pattern of the TLP headers to trace */ struct hisi_ptt_trace_ctrl { struct hisi_ptt_dma_buffer *trace_buf; @@ -139,6 +142,7 @@ struct hisi_ptt_trace_ctrl { u32 filter:16; u32 format:1; u32 type:4; + u32 pattern:1; }; =20 /* --=20 2.33.0 From nobody Sat Sep 26 08:38:48 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2390242A792; Thu, 3 Sep 2026 07:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421994; cv=none; b=XoxsMdxQ+q4dhZOE5iXzfcxc5mH89h+zcPmCxZwGaBZr5vcT1jEwYRclOk4n+PHgOgxNyDz2tPeZcNgJ/HmLeFZiG/5VZ1VjSi7i4cvdaQligz7nEjdZdTHiOsu1AN0vddAQ5Aa4LUkb9XMbJTbJxjrfZUbUHV48VLSXylEXW9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421994; c=relaxed/simple; bh=SJFdmTNr7UP3RMAgI2ppuZnpICv8Z409nx6uDJZqQdA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e6C9mK0d6/CExPQaKxgbZxjMsvVR+eD+KpFbTBiizNRnQwOcyVnXmg6MwOm2OJfX6yI4Tunw2N6C+nYjMimMJYaohHt/VSCAsrH8lD1u7M9+5XfgW/WCcXmP9I56DnbWH2rs+En8eDop9Xp/37023m/HKr5IElR7m/IVv0CyF4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=o1HvJD05; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="o1HvJD05" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=FlgWR0GK8oRJCmI0bKBgUGXlNscM2W4qlGKgsGqwKKc=; b=o1HvJD05Q93ovUis5/GXFwcfytQCV9+isnXx3wQjrpslY+RpuCUPpH0bQSD6/O1x5YEAaGLsb TCTZzg6k9oiowjaeO+fPC8yGWq9cm37GkuEWAMCEgIYn2SKEVtnGlP3tj0eEcahybKCyMifsKdb J5ZAeVtebSBg9CwOb9movBw= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hbBPJ5GKKzpSvD; Thu, 3 Sep 2026 15:41:40 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 24E434057F; Thu, 3 Sep 2026 15:53:03 +0800 (CST) Received: from huawei.com (10.50.163.32) by whupemo200004.china.huawei.com (7.152.184.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 3 Sep 2026 15:53:00 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v3 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Date: Thu, 3 Sep 2026 15:52:41 +0800 Message-ID: <20260903075241.1445338-9-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260903075241.1445338-1-liusizhe5@huawei.com> References: <20260903075241.1445338-1-liusizhe5@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Sizhe Liu --- tools/perf/arch/arm64/util/hisi-ptt.c | 18 +++++++++ .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 39 ++++++++++++------- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 8 ++-- tools/perf/util/hisi-ptt.c | 28 +++++++++---- tools/perf/util/hisi-ptt.h | 9 ++++- 5 files changed, 72 insertions(+), 30 deletions(-) diff --git a/tools/perf/arch/arm64/util/hisi-ptt.c b/tools/perf/arch/arm64/= util/hisi-ptt.c index 52257715d2b7..ae8c16b5c324 100644 --- a/tools/perf/arch/arm64/util/hisi-ptt.c +++ b/tools/perf/arch/arm64/util/hisi-ptt.c @@ -6,6 +6,7 @@ =20 #include #include +#include #include #include #include @@ -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 =3D container_of(itr, struct hisi_ptt_recording, itr); struct perf_pmu *hisi_ptt_pmu =3D pttr->hisi_ptt_pmu; + struct evsel *evsel; + u32 pattern =3D 0; =20 if (priv_size !=3D HISI_PTT_AUXTRACE_PRIV_SIZE) return -EINVAL; @@ -56,8 +60,22 @@ static int hisi_ptt_info_fill(struct auxtrace_record *it= r, if (!evlist__core(session->evlist)->nr_mmaps) return -EINVAL; =20 + /* + * 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 =3D=3D hisi_ptt_pmu->type) { + pattern =3D FIELD_GET(HISI_PTT_PMU_PATTERN_MASK, + evsel->core.attr.config); + break; + } + } + auxtrace_info->type =3D PERF_AUXTRACE_HISI_PTT; auxtrace_info->priv[0] =3D hisi_ptt_pmu->type; + auxtrace_info->priv[1] =3D pattern; =20 return 0; } diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c b/tool= s/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c index de1d4071e209..63700380bf91 100644 --- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c +++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c @@ -20,7 +20,7 @@ /* * For 8DW format, the bit[31:11] of DW0 is always 0x1fffff, which can be * used to distinguish the data format. - * 8DW format is like: + * 8DW format legacy pattern is like: * bits [ 31:11 ][ 10:0 ] * |---------------------------------------|-------------------| * DW0 [ 0x1fffff ][ Reserved (0x7ff) ] @@ -32,7 +32,7 @@ * DW6 [ Reserved (0x0) ] * DW7 [ Time ] * - * 4DW format is like: + * 4DW format legacy pattern is like: * bits [31:30] [ 29:25 ][24][23][22][21][ 20:11 ][ 10:0 ] * |-----|---------|---|---|---|---|-------------|-------------| * DW0 [ Fmt ][ Type ][T9][T8][TH][SO][ Length ][ Time ] @@ -79,6 +79,11 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = =3D { [HISI_PTT_4DW_HEAD3] =3D "Header DW3", }; =20 +static int hisi_ptt_pkt_size[] =3D { + [HISI_PTT_4DW_PKT] =3D 16, + [HISI_PTT_8DW_PKT] =3D 32, +}; + /* TLP message parsers below according to PCIe r6.4 sec 2.2.1.1 & 2.2.1.2 = */ static bool hisi_ptt_is_mwr_tlp(uint32_t format, uint32_t type) { @@ -207,15 +212,20 @@ static void hisi_ptt_print_head1(struct hisi_ptt_pkt_= buf *pkt_buf) static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf) { const char *color =3D PERF_COLOR_BLUE; + const char *desc =3D pkt_buf->pkt_type =3D=3D 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; =20 dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); hisi_ptt_print_raw_record(pkt_buf->pos, dw); =20 - if (pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_MWR || - pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_MSG || - pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_ATOM || - pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_IO) + if (pkt_buf->pattern < HISI_PTT_PATTERN_V1) + color_fprintf(stdout, color, " %s\n", desc); + else if (pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_MWR || + pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_MSG || + pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_ATOM || + pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_IO) color_fprintf(stdout, color, " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", "Reserved", @@ -229,10 +239,7 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_b= uf *pkt_buf) "Header DW2", FIELD_GET(HISI_PTT_HEAD2_HEADER_DW2, dw)); else - color_fprintf(stdout, color, " %s\n", - pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT ? - hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD2] : - hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD2]); + color_fprintf(stdout, color, " %s\n", desc); =20 pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } @@ -240,12 +247,17 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_= buf *pkt_buf) static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf) { const char *color =3D PERF_COLOR_BLUE; + const char *desc =3D pkt_buf->pkt_type =3D=3D 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; =20 dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); hisi_ptt_print_raw_record(pkt_buf->pos, dw); =20 - if (pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_CPL) + if (pkt_buf->pattern < HISI_PTT_PATTERN_V1) + color_fprintf(stdout, color, " %s\n", desc); + else if (pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_CPL) color_fprintf(stdout, color, " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", "Destination Segment", @@ -272,10 +284,7 @@ static void hisi_ptt_print_head3(struct hisi_ptt_pkt_b= uf *pkt_buf) "Header DW3", FIELD_GET(HISI_PTT_HEAD3_CFG_HEADER_DW3, dw)); else - color_fprintf(stdout, color, " %s\n", - pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT ? - hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD3] : - hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD3]); + color_fprintf(stdout, color, " %s\n", desc); =20 pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h b/tool= s/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h index 61bf3b11a467..44735db5ec31 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 @@ -17,6 +17,8 @@ #define HISI_PTT_IS_8DW_PKT GENMASK(31, 11) #define HISI_PTT_MAX_SPACE_LEN 10 #define HISI_PTT_FIELD_LENGTH 4 +#define HISI_PTT_PATTERN_LEGACY 0 +#define HISI_PTT_PATTERN_V1 1 =20 /* Header DW0 fields for 4DW format */ #define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0) @@ -77,11 +79,6 @@ enum hisi_ptt_pkt_type { HISI_PTT_PKT_MAX }; =20 -static int hisi_ptt_pkt_size[] =3D { - [HISI_PTT_4DW_PKT] =3D 16, - [HISI_PTT_8DW_PKT] =3D 32, -}; - enum hisi_ptt_pkt_msg_type { HISI_PTT_PKT_TYPE_UNKNOWN, /* Types do not support analysis */ HISI_PTT_PKT_TYPE_MWR, /* P-(MemWr) */ @@ -99,6 +96,7 @@ struct hisi_ptt_pkt_buf { size_t len; enum hisi_ptt_pkt_type pkt_type; enum hisi_ptt_pkt_msg_type pkt_msg_type; + size_t pattern; }; =20 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[] =3D { + [HISI_PTT_4DW_PKT] =3D 16, + [HISI_PTT_8DW_PKT] =3D 32, }; =20 static enum hisi_ptt_pkt_type hisi_ptt_check_packet_type(unsigned char *bu= f, @@ -53,8 +59,7 @@ static enum hisi_ptt_pkt_type hisi_ptt_check_packet_type(= unsigned char *buf, return HISI_PTT_4DW_PKT; } =20 -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 =3D PERF_COLOR_BLUE; struct hisi_ptt_pkt_buf pkt_buf; @@ -64,8 +69,9 @@ static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_un= used, pkt_buf.pkt_type =3D hisi_ptt_check_packet_type(buf, len); pkt_buf.len =3D round_down(len, hisi_ptt_pkt_size[pkt_buf.pkt_type]); pkt_buf.pkt_msg_type =3D HISI_PTT_PKT_TYPE_UNKNOWN; - color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n", - pkt_buf.len); + pkt_buf.pattern =3D (size_t)ptt->pattern; + color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes, patter= n %zu\n", + pkt_buf.len, pkt_buf.pattern); =20 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_se= ssion *session, return evsel->core.attr.type =3D=3D ptt->pmu_type; } =20 -static void hisi_ptt_print_info(__u64 type) +static void hisi_ptt_print_info(u32 type, u32 pattern) { if (!dump_trace) return; =20 - fprintf(stdout, " PMU Type %" PRId64 "\n", (s64) type); + fprintf(stdout, " PMU Type %" PRIu32 "\n", type); + fprintf(stdout, " Data Pattern %" PRIu32 "\n", pattern); } =20 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 =3D &event->auxtrace_info; struct hisi_ptt *ptt; + size_t priv_size; =20 - 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 =3D auxtrace_info->header.size - + sizeof(struct perf_record_auxtrace_info); =20 ptt =3D zalloc(sizeof(*ptt)); if (!ptt) @@ -184,6 +194,8 @@ int hisi_ptt_process_auxtrace_info(union perf_event *ev= ent, ptt->machine =3D &session->machines.host; /* No kvm support */ ptt->auxtrace_type =3D auxtrace_info->type; ptt->pmu_type =3D auxtrace_info->priv[0]; + ptt->pattern =3D priv_size >=3D HISI_PTT_AUXTRACE_PRIV_SIZE_V1 ? + (u32)auxtrace_info->priv[1] : HISI_PTT_PATTERN_LEGACY; =20 ptt->auxtrace.process_event =3D hisi_ptt_process_event; ptt->auxtrace.process_auxtrace_event =3D hisi_ptt_process_auxtrace_event; @@ -193,7 +205,7 @@ int hisi_ptt_process_auxtrace_info(union perf_event *ev= ent, ptt->auxtrace.evsel_is_auxtrace =3D hisi_ptt_evsel_is_auxtrace; session->auxtrace =3D &ptt->auxtrace; =20 - hisi_ptt_print_info(auxtrace_info->priv[0]); + hisi_ptt_print_info(ptt->pmu_type, ptt->pattern); =20 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__ =20 -#define HISI_PTT_PMU_NAME "hisi_ptt" -#define HISI_PTT_AUXTRACE_PRIV_SIZE sizeof(u64) +#include + +#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) =20 struct auxtrace_record *hisi_ptt_recording_init(int *err, struct perf_pmu *hisi_ptt_pmu); --=20 2.33.0