From nobody Mon Jun 8 09:49:04 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 C795434A76A; Thu, 4 Jun 2026 07:50:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559414; cv=none; b=JCXtXDKtlf28Bo1+W55HEWcAv6vFEj0J7o/zwMN0ANu8BEL+UyRquUTqaxR9P0Kr8UEh+K0iuCtnN5b+/s+L3/o98RRcCvoy6Lw8zx4iyhT9t8ljVtIOVEHEgATzZa++Hv+s8SSG3hrN8q61KQuJ1cj7FXa1MG0je1rr1e/DM1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559414; c=relaxed/simple; bh=DbOzlWJwPPwSCdtDroAeYMVmB7fY1dkx5sDks1j9GgQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lw6Q1gTy8yE/PRbHOKilE1exQsgxdbigxziRhHrkoVdz0a+xlsUgA15k7AglpjxFFo0++UjP6D2G3pDnwiLhvsOXV0zCbCfyhfkVwSBUGUEi3vI+EjbjMqnQDDwfBtsKsaodeXZTqZt9fsrfBL4Cy7hwsrIXQPWEREVN0xuAUKU= 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=Pn03m0U8; arc=none smtp.client-ip=113.46.200.227 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="Pn03m0U8" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=cWe+vZO8oMF8iNfLKj+yBqRETDq4Lrm39k4z5xsUJ0I=; b=Pn03m0U8N/O5z/ABeFdtW7TR4YtFtE2huApdQvQBo84LcKAuMZzPV3ocTwkNuWCyUav7KyR+F 8O8TnRIteVURwaBao6wRavJHRONmJ+ZV3bBJ09uek8Eguj+Gl+BuADSq8aJntiYizUO5XWByfNX OajjJrrgtClaQstRSd9dSGk= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4gWGjz4fbWznTY6; Thu, 4 Jun 2026 15:42:15 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 3C6F940565; Thu, 4 Jun 2026 15:50:08 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:08 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:06 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 01/10] perf hisi-ptt: Fix spelling and abbreviation errors Date: Thu, 4 Jun 2026 15:49:56 +0800 Message-ID: <20260604075005.2219785-2-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) Content-Type: text/plain; charset="utf-8" Fix spelling and abbreviation errors in the PTT packet decoder: - HISI_PTT_FIELD_LENTH -> HISI_PTT_FIELD_LENGTH - hisi_ptt_8dw_kpt_desc -> hisi_ptt_8dw_pkt_desc - hisi_ptt_4dw_kpt_desc -> hisi_ptt_4dw_pkt_desc Cc: stable@vger.kernel.org Fixes: 5e91e57e6809 ("perf auxtrace arm64: Add support for parsing HiSilico= n PCIe Trace packet") Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 20 +++++++++---------- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 2 +- 2 files changed, 11 insertions(+), 11 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 a17c423a526d..c48b2ce7c4a3 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 @@ -94,26 +94,26 @@ static void hisi_ptt_print_pkt(const unsigned char *buf= , int pos, const char *de =20 printf("."); color_fprintf(stdout, color, " %08x: ", pos); - for (i =3D 0; i < HISI_PTT_FIELD_LENTH; i++) + for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) color_fprintf(stdout, color, "%02x ", buf[pos + i]); for (i =3D 0; i < HISI_PTT_MAX_SPACE_LEN; i++) color_fprintf(stdout, color, " "); color_fprintf(stdout, color, " %s\n", desc); } =20 -static int hisi_ptt_8dw_kpt_desc(const unsigned char *buf, int pos) +static int hisi_ptt_8dw_pkt_desc(const unsigned char *buf, int pos) { 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_LENTH; + 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_LENTH; + pos +=3D HISI_PTT_FIELD_LENGTH; } =20 return hisi_ptt_pkt_size[HISI_PTT_8DW_PKT]; @@ -128,7 +128,7 @@ static void hisi_ptt_4dw_print_dw0(const unsigned char = *buf, int pos) dw0.value =3D *(uint32_t *)(buf + pos); printf("."); color_fprintf(stdout, color, " %08x: ", pos); - for (i =3D 0; i < HISI_PTT_FIELD_LENTH; i++) + for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) color_fprintf(stdout, color, "%02x ", buf[pos + i]); for (i =3D 0; i < HISI_PTT_MAX_SPACE_LEN; i++) color_fprintf(stdout, color, " "); @@ -140,16 +140,16 @@ static void hisi_ptt_4dw_print_dw0(const unsigned cha= r *buf, int pos) dw0.len, "Time", dw0.time); } =20 -static int hisi_ptt_4dw_kpt_desc(const unsigned char *buf, int pos) +static int hisi_ptt_4dw_pkt_desc(const unsigned char *buf, int pos) { int i; =20 hisi_ptt_4dw_print_dw0(buf, pos); - pos +=3D HISI_PTT_FIELD_LENTH; + pos +=3D HISI_PTT_FIELD_LENGTH; =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_LENTH; + pos +=3D HISI_PTT_FIELD_LENGTH; } =20 return hisi_ptt_pkt_size[HISI_PTT_4DW_PKT]; @@ -158,7 +158,7 @@ static int hisi_ptt_4dw_kpt_desc(const unsigned char *b= uf, int pos) int hisi_ptt_pkt_desc(const unsigned char *buf, int pos, enum hisi_ptt_pkt= _type type) { if (type =3D=3D HISI_PTT_8DW_PKT) - return hisi_ptt_8dw_kpt_desc(buf, pos); + return hisi_ptt_8dw_pkt_desc(buf, pos); =20 - return hisi_ptt_4dw_kpt_desc(buf, pos); + return hisi_ptt_4dw_pkt_desc(buf, pos); } 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 e78f1b5bc836..6772b16b817b 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 @@ -13,7 +13,7 @@ #define HISI_PTT_8DW_CHECK_MASK GENMASK(31, 11) #define HISI_PTT_IS_8DW_PKT GENMASK(31, 11) #define HISI_PTT_MAX_SPACE_LEN 10 -#define HISI_PTT_FIELD_LENTH 4 +#define HISI_PTT_FIELD_LENGTH 4 =20 enum hisi_ptt_pkt_type { HISI_PTT_4DW_PKT, --=20 2.33.0 From nobody Mon Jun 8 09:49:04 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 485B23CF97F; Thu, 4 Jun 2026 07:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559420; cv=none; b=JkQo6iX73UlbXH8dbud11tzhsoHDASGxk3OvGzqVkiDAj1CbOOxetImV1ePHwGPz0vr22sPT9sWgtkkTcWBrlxOrnOhpf/eRKqpLeeptfk1y4iLZUB+HKOwOtntCtx6M2S4oqYRoVz85D4nSINulS3l/NK68gtozaEbrorEM76w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559420; c=relaxed/simple; bh=mW4cgkiY+KVchz44fwvtX3z4vBi8nEZVepIbIkTxg5g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PNuIAYyW+Xh6zGDa2PfCI/vyZFfJWGmXcxOc2n5VnnD+BrTouhmWsxa0HFNUBX6fUvTtIspS5e/1k+hK8c8/t6oorK0qZ1kU1S8UjmJvcDvIBNIX8/BZV4P/M+tzdGO0lhxBOASWIoNh9YVtJeCJVsu4IMhBxswaKHgwTOwic5E= 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=WH/gBSSH; arc=none smtp.client-ip=113.46.200.226 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="WH/gBSSH" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Ts2iYOlNKH3kWFa5rVVu9XfgvOuT/GxiEr87iyKRZdg=; b=WH/gBSSHVf9VXwlXAHa5ElbV+aucjJmYuCIctUTcGAf8dRCwRPe+0aqhiFGvYOb5sLqRWoDNZ zH3Sa/ejc8FEgjZ+77oaweKi8p7oYa+hYUEvROVIctbEXLhdodm7R6/tsJ36ABZJ2gjhHX0GL5F /A0+xVeUx7684OTjwwW+8aA= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk01W7XzKm8N; Thu, 4 Jun 2026 15:42:16 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id 348594055B; Thu, 4 Jun 2026 15:50:09 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:08 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:07 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 02/10] perf hisi-ptt: Fix PTT trace TLP Header parsing Date: Thu, 4 Jun 2026 15:49:57 +0800 Message-ID: <20260604075005.2219785-3-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) Content-Type: text/plain; charset="utf-8" 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 HiSilico= n PCIe Trace packet") Signed-off-by: Sizhe Liu --- 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-pt= t.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 8D= W 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/tool= s/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 #include #include +#include =20 #include "../color.h" #include "hisi-ptt-pkt-decoder.h" @@ -75,14 +76,14 @@ static const char * const hisi_ptt_4dw_pkt_field_name[]= =3D { =20 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 ch= ar *desc) { const char *color =3D PERF_COLOR_BLUE; + uint32_t value; + uint8_t byte; int i; =20 + value =3D le32_to_cpu(*(__le32 *)(buf + pos)); printf("."); color_fprintf(stdout, color, " %08x: ", pos); - for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) - color_fprintf(stdout, color, "%02x ", buf[pos + i]); + for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { + 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, " "); color_fprintf(stdout, color, " %s\n", desc); @@ -123,13 +129,16 @@ static void hisi_ptt_4dw_print_dw0(const unsigned cha= r *buf, int pos) { const char *color =3D PERF_COLOR_BLUE; union hisi_ptt_4dw dw0; + uint8_t byte; int i; =20 - dw0.value =3D *(uint32_t *)(buf + pos); + dw0.value =3D le32_to_cpu(*(__le32 *)(buf + pos)); printf("."); color_fprintf(stdout, color, " %08x: ", pos); - for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) - color_fprintf(stdout, color, "%02x ", buf[pos + i]); + for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { + byte =3D (dw0.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, " "); =20 --=20 2.33.0 From nobody Mon Jun 8 09:49:04 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 356DBCA45; Thu, 4 Jun 2026 07:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559415; cv=none; b=BdE6hChZtjbtPqoq+NA+CMuAYJDaEcVloZnhlQLYU4Whyj4K6VnrlF/odq0zvOFCMc7K0ZEZkc8hN+/a6ZbS6ok4LOMCpFyTvW0+CvLxJVyUkLx4CGbKGDgzX1xBwMtRdq5pGNVzN9YcCb4srhrtNlWOSMZI9vW//QZ5wMn7ZLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559415; c=relaxed/simple; bh=Xi6jLInEcETVU5w4SaocDXndF2bqdv5LK+f5Mt49hbc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n1kZLLcQW1NigutFDqr+ynIF9TVt5E37zkjHsj4oEXBWteWIvbDUnqErJNiTnrrXwM5YJ16DTv5elx8yeC8EmPl0P3rGc6lI4BH5Vg8ih9lxkirvnpX6vaokO8GKGZ5DDV/aWK0KowE8ZaCP7P/Mt47Tq/SANpLxYDrYs1PyYMo= 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=rYmGZPSE; arc=none smtp.client-ip=113.46.200.227 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="rYmGZPSE" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=b539C+AawPNqTUMTRaV+ozcrDgitM+hGFWLgyJ7L8wc=; b=rYmGZPSEvc1o55e0ayzpTaHAV3hJcI8qHt0pXiNu26au/R27FzaE4egOodIf4xP/fpjWAXTAr USf31VnVXyQvuClXD+dFpSFLdgEtX31GohzHk2bxQQORsnKynDljKsAZatZMsWIJ4izGpRa9ZPG d+n0A4aVfZ6Uz86n8yjI1Io= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk13jKbznTbR; Thu, 4 Jun 2026 15:42:17 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 1D86B4055B; Thu, 4 Jun 2026 15:50:10 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:09 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:08 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 03/10] perf hisi-ptt: Rename hisi_ptt_4dw union for reuse Date: Thu, 4 Jun 2026 15:49:58 +0800 Message-ID: <20260604075005.2219785-4-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) Content-Type: text/plain; charset="utf-8" Rename union hisi_ptt_4dw to hisi_ptt_field_data so that it can hold bit field layouts for different DW headers. Add the struct member name dw0_4dw to indicate that the inner struct is for 4DW format DW0. Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 18 ++++++++++-------- 1 file changed, 10 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 67024f18ebbb..5daae2eaf435 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 @@ -74,7 +74,8 @@ static const char * const hisi_ptt_4dw_pkt_field_name[] = =3D { [HISI_PTT_4DW_HEAD3] =3D "Header DW3", }; =20 -union hisi_ptt_4dw { +union hisi_ptt_field_data { + /* Header DW0 for 4DW format */ struct { uint32_t time : 11; uint32_t len : 10; @@ -84,7 +85,7 @@ union hisi_ptt_4dw { uint32_t t9 : 1; uint32_t type : 5; uint32_t format : 2; - }; + } dw0_4dw; uint32_t value; }; =20 @@ -128,15 +129,15 @@ static int hisi_ptt_8dw_pkt_desc(const unsigned char = *buf, int pos) static void hisi_ptt_4dw_print_dw0(const unsigned char *buf, int pos) { const char *color =3D PERF_COLOR_BLUE; - union hisi_ptt_4dw dw0; + union hisi_ptt_field_data dw; uint8_t byte; int i; =20 - dw0.value =3D le32_to_cpu(*(__le32 *)(buf + pos)); + dw.value =3D le32_to_cpu(*(__le32 *)(buf + pos)); printf("."); color_fprintf(stdout, color, " %08x: ", pos); for (i =3D 0; i < HISI_PTT_FIELD_LENGTH; i++) { - byte =3D (dw0.value >> (24 - i * 8)) & 0xFF; + byte =3D (dw.value >> (24 - i * 8)) & 0xFF; color_fprintf(stdout, color, "%02x ", byte); } for (i =3D 0; i < HISI_PTT_MAX_SPACE_LEN; i++) @@ -144,9 +145,10 @@ static void hisi_ptt_4dw_print_dw0(const unsigned char= *buf, int pos) =20 color_fprintf(stdout, color, " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", - "Format", dw0.format, "Type", dw0.type, "T9", dw0.t9, - "T8", dw0.t8, "TH", dw0.th, "SO", dw0.so, "Length", - dw0.len, "Time", dw0.time); + "Format", dw.dw0_4dw.format, "Type", dw.dw0_4dw.type, + "T9", dw.dw0_4dw.t9, "T8", dw.dw0_4dw.t8, + "TH", dw.dw0_4dw.th, "SO", dw.dw0_4dw.so, + "Length", dw.dw0_4dw.len, "Time", dw.dw0_4dw.time); } =20 static int hisi_ptt_4dw_pkt_desc(const unsigned char *buf, int pos) --=20 2.33.0 From nobody Mon Jun 8 09:49:04 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 EB82B369D7A; Thu, 4 Jun 2026 07:50:13 +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=1780559416; cv=none; b=WocybAeNzNeYSXSYOskf0l7XHjSUp/KkcmN2CSB0WdjjOKImi4Lc5lysu3CorwCUVagb5upuKG4hbq9WvtIuI0+Dp2xVjZ+QtPFLTXQJ4xpg4yHA/tpFIUA11zMf4ZqBZF/NhcpLYjKZ1qlzwFhi48BBRsv6aho63lqtI7xNUQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559416; c=relaxed/simple; bh=D1yC5i7+02JAjldctHFsWB5ABSgISt5vlM1Tm6yIzfQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c7s247aajNaPjrgytlgPcOoLMD6pJ2D8n3pSKhLefT+DIDrYAWxCIFC272Io7FQVCOqmGjItYwy+gj/YLCryB6cC0rZsdkKmJ/Ii8JPkFBm1ztujLm5TnQqYtbnozXjyUgJWTGNG2XHZqSU3gk4hlOmSDgLBpvp1JxbnCGVRoeY= 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=ZB2LJn4Y; 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="ZB2LJn4Y" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=55jJZ4b6FSuLirTwSnzlWie3FXn/0XRNBJg5K5NHKg4=; b=ZB2LJn4YFeV80oHV762/e+OONkYFYD1eOfWhFoUtuv1IkW/vatj2/qd0acsc3xthVj0/QNOti 5MYR0y+k2+dcgryJqQ6f5AeZqz7cLeynIY4/o0LICpEb45m963U6aBuNoMU2c9BHiqt4OOLffKH nT6kqwBLAiBLgyCSSG/bUB8= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk46r9PzLlTV; Thu, 4 Jun 2026 15:42:20 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 196634055B; Thu, 4 Jun 2026 15:50:11 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:10 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:09 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 04/10] perf hisi-ptt: Abstract trace data buf and offset Date: Thu, 4 Jun 2026 15:49:59 +0800 Message-ID: <20260604075005.2219785-5-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) 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 function. Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 39 ++++++++++--------- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 9 ++++- tools/perf/util/hisi-ptt.c | 20 ++++------ 3 files changed, 36 insertions(+), 32 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 5daae2eaf435..201ca948c4fb 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 @@ -89,16 +89,17 @@ union hisi_ptt_field_data { uint32_t value; }; =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; uint32_t value; uint8_t byte; int i; =20 - value =3D le32_to_cpu(*(__le32 *)(buf + pos)); + value =3D le32_to_cpu(*(__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 (value >> (24 - i * 8)) & 0xFF; color_fprintf(stdout, color, "%02x ", byte); @@ -106,36 +107,36 @@ static void hisi_ptt_print_pkt(const unsigned char *b= uf, 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; union hisi_ptt_field_data dw; uint8_t byte; int i; =20 - dw.value =3D le32_to_cpu(*(__le32 *)(buf + pos)); + dw.value =3D le32_to_cpu(*(__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.value >> (24 - i * 8)) & 0xFF; color_fprintf(stdout, color, "%02x ", byte); @@ -149,27 +150,27 @@ static void hisi_ptt_4dw_print_dw0(const unsigned cha= r *buf, int pos) "T9", dw.dw0_4dw.t9, "T8", dw.dw0_4dw.t8, "TH", dw.dw0_4dw.th, "SO", dw.dw0_4dw.so, "Length", dw.dw0_4dw.len, "Time", dw.dw0_4dw.time); + + 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; + 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 6772b16b817b..316f24f01068 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,6 +26,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 e4cc4785f744..4efda3f3e5f9 100644 --- a/tools/perf/util/hisi-ptt.c +++ b/tools/perf/util/hisi-ptt.c @@ -49,22 +49,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 =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); + 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 Mon Jun 8 09:49:04 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 B1BD713D886; Thu, 4 Jun 2026 07:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559416; cv=none; b=FQHRriEHa6cgg+OrIcVaXK3zLC+9xyMDc0BAMdeV+eQ+HnJzGTTK3LxS5stAhhGOZ2OWu70/mVWE1NFdr32JsnJ9r/Shtwy/PKrnsSNdCImU1A82uvXGcet8VmFzbu+Le58tAOic/fWqQCPq0nhghf0uCr0xhjCUeOkV6bpe/sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559416; c=relaxed/simple; bh=7ygI4Q9f2BRqbBfETY59Y6aBCjkFRgbKUqQZNV40UrU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dMhEuj6ZLUSKX+ICJ9Ma+mRI3oqruTMSBP0ugUeMgLYEQF6qEZCFRNBuc7f6YTGHSJIuzxPakl5dCNEOk9Zel+Gf4CwOlUrVIPxJ/cX1VUZFrw187VItVcgEHfY15bbOUSeDq6aMohc+cty9IuuvSMbbK5zbGGzs/2+FhRLqVKE= 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=knSCBs2Q; arc=none smtp.client-ip=113.46.200.227 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="knSCBs2Q" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Ato99urV+TJI9keJXJxq4w1QU/DPwW65iRUxfGjeLIg=; b=knSCBs2QrywHvIxahoy+tlt1DC5xIp19y612n7v380yC5+Djn/8DqZmAY0yc2ZarA3P5BXXds 5MNCI0LSYI7kd2W6fBhxeYbEL5IrMBRQoiv/j2D0gM373E2Hzzb9CLLxGlSZXxU6YKWyBYitJjn zw89k4odiC86Mx0vzw2VyWo= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk33RWBznTZ3; Thu, 4 Jun 2026 15:42:19 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id 1086840565; Thu, 4 Jun 2026 15:50:12 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:11 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:10 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 05/10] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Date: Thu, 4 Jun 2026 15:50:00 +0800 Message-ID: <20260604075005.2219785-6-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) 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. Replace the variable in the printing loop with enum members. 8DW format is like: bits [ 31:11 ][ 10:0 ] |---------------------------------------|-------------------| DW0 [ 0x1fffff ][ Reserved (0x7ff) ] DW1 [ Prefix ] DW2 [ Header DW0 ] DW3 [ Header DW1 ] DW4 [ Header DW2 ] DW5 [ Header DW3 ] DW6 [ Reserved (0x0) ] DW7 [ Time ] Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 21 +++++++++++-------- 1 file changed, 12 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 201ca948c4fb..33804bcd0642 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 @@ -53,6 +53,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, @@ -60,15 +61,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", @@ -114,7 +118,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; @@ -160,9 +164,8 @@ 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 Mon Jun 8 09:49:04 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 587613E557F; Thu, 4 Jun 2026 07:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559424; cv=none; b=EH0YQxoPo9yye83TFzN+l1ZM8VdxwEA2hPJULY/Lg7Sk3aDsi+kbek/pyvwEIYJh0SB2jbtJdirA81xYnM5eSFS/WGdzIBgAN7CWimmWnu1Yy1AXd6P9YGGujIw+UXp5XN57QyXtfHgzCXEGPgem8IpowAuEAONrsT0/FQ1VV8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559424; c=relaxed/simple; bh=eBl7APe5jVZi7hoPd7kvqsAHdY+d01qiMcr5hmb5kgE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GzqswCoMT4sdL3Y6lMEGmnTxcrbFJwlrpXllkQ3dcMB7igkPua+OUJ4cDsdWHcqYIZdLgmZi5NQVKpj2zSAG0fwPGPf49qCtGIhivrB/A0pXU/tgvUa5hdNdyjOM2J5N/fxa0MEUQdP8U+cBSVU5gyiyIyeIB939Sw667snXnuY= 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=fBAgDHAp; arc=none smtp.client-ip=113.46.200.226 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="fBAgDHAp" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=KCmlyUAoK/yHveusUi6OJxnEgjrVkZLbwQEppi6gKxM=; b=fBAgDHApSydyIm9IrNbVHVRassbBcy5cDEsGBBor5twX6mUu2BgcUTbf+dAisAqBMatksZCj6 T5Q8LaP+ikQqELdVxa5dD3javmt8Ua9x06oCTU5IpnmL/MJApzaVAvdVIgu8VbXxRT7x4KNMdGs utWEFfXKdP4WPVlJzhkVXW4= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk416xVzKmTk; Thu, 4 Jun 2026 15:42:20 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 26D1940565; Thu, 4 Jun 2026 15:50:13 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:12 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:11 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 06/10] perf hisi-ptt: Extract the raw data printing part Date: Thu, 4 Jun 2026 15:50:01 +0800 Message-ID: <20260604075005.2219785-7-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) 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. Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 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 33804bcd0642..a5b66e0f7827 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 @@ -93,23 +93,31 @@ union hisi_ptt_field_data { uint32_t value; }; =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; - uint32_t value; uint8_t byte; int i; =20 - value =3D le32_to_cpu(*(__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 (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 le32_to_cpu(*(__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; } @@ -135,18 +143,9 @@ static void hisi_ptt_4dw_print_dw0(struct hisi_ptt_pkt= _buf *pkt_buf) { const char *color =3D PERF_COLOR_BLUE; union hisi_ptt_field_data dw; - uint8_t byte; - int i; =20 dw.value =3D le32_to_cpu(*(__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.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, " "); + hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); =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 Mon Jun 8 09:49:04 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 65E183CF049; Thu, 4 Jun 2026 07:50:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559420; cv=none; b=d+L0CyzYkMz7bx5RYXA+DXfCPK890Kg2/8EByxESE3USfsFP61l2G61UBTRU7puBUqs+1QuS2TOvyL6T5iGYco5RdCKb3L0ji4ehOxcXNXxXXgADADLEHtMLb71u5y1VOjX3iQRyl6ym6mfPa+mokXVrGxkIjfz/e1YN7Nq1hiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559420; c=relaxed/simple; bh=Ro6/E6xOKUCBYhaGNxYd4ktvW7scQZL/Dy3q1Qt6rlk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jn4DnNpyZOldiQjq9qWioUkRP3cuPlVMxowfv6fz5JWhkGlJnOU8xy/N8ynh9CdVB2LC8sK7ph0SON+DfRT7hV7LOos0wu7ZbnTw5mT8sJwmwsDW1XB0wTjCfecrmu37N9GWCvUhQrqk6eUhG3YYqDBfG7KG0cwac0VUFezNj9c= 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=wkgUTtvc; arc=none smtp.client-ip=113.46.200.223 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="wkgUTtvc" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=U0bZ6/5IF5u6IblAtoXo0vDn8/JhU8/jFh51QnHbslU=; b=wkgUTtvcqEqDW31caCt5WvhxzdZJkB2iN2lbhp5RtvQUsgWZLl/iVTR44OwRC6w6WjZunmttz +79tkYmqdUVEVyWorwp+I0e810IT1jdrXQy9sJhXbOCjDluvQLSaifLXbTUNnXywGmDlvQ/kY6n y7xmAWuqpclxcp8ztcNTHG4= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk62qtPzmVW0; Thu, 4 Jun 2026 15:42:22 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 24B4440561; Thu, 4 Jun 2026 15:50:14 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:13 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:12 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 07/10] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Date: Thu, 4 Jun 2026 15:50:02 +0800 Message-ID: <20260604075005.2219785-8-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) 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. Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 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 a5b66e0f7827..9ec84d398cc1 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 @@ -122,6 +122,30 @@ 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; + union hisi_ptt_field_data dw; + + dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); + hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); + + 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", dw.dw0_4dw.format, + "Type", dw.dw0_4dw.type, + "T9", dw.dw0_4dw.t9, "T8", dw.dw0_4dw.t8, + "TH", dw.dw0_4dw.th, "SO", dw.dw0_4dw.so, + "Length", dw.dw0_4dw.len, + "Time", dw.dw0_4dw.time); + 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; @@ -133,35 +157,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; - union hisi_ptt_field_data dw; - - dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); - hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); - - color_fprintf(stdout, color, - " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", - "Format", dw.dw0_4dw.format, "Type", dw.dw0_4dw.type, - "T9", dw.dw0_4dw.t9, "T8", dw.dw0_4dw.t8, - "TH", dw.dw0_4dw.th, "SO", dw.dw0_4dw.so, - "Length", dw.dw0_4dw.len, "Time", dw.dw0_4dw.time); - - 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 Mon Jun 8 09:49:04 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 673623E0256; Thu, 4 Jun 2026 07:50:17 +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=1780559421; cv=none; b=d9nNJA4ci4W3/giIWeKdnJNCVXV7rLeIn9DRQN/LmjOLSWlp/pw06/OH2OJya4bMOzuJTznpWch55570Mm+COLMQceb3TwKthG73lH6qiKRGXoSVR+7ILmoSs4K5PrGjHq+GOBsgID2dizu7Q7SQh+oHxMqFXL1h1FWXXVEohVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559421; c=relaxed/simple; bh=d6WNyRQLNCKZnwdJSL03cpJ7nW5A3poxj03Y4QHijPw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aP70gNYH0geuJS618sUIAhZEJ9YF460QPF4O9aAXheD7s5cXJBwsY530Jdy4AYqI4E7Ng4NrCzSMYcx7yTh3zcdOwL2caMmvxvzrKbZs7nr8iNSm5Fs+YwfXilQX+N6ufssuEcx/bpzb7XPIsOk9Pikf/fFQ3k2xGrYpzOTt5wM= 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=54CiqROR; 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="54CiqROR" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=GfAqjfAKuKALPlMmSy4yHgVtiTcX8QOSrT0p3ACFQnQ=; b=54CiqRORWSEtNm7PVg0ThWRYLX4tReDgiVK/tiq5D0YJEg/XV4YsNHBe+tJI4QnyYv3HDb3wp 3kMekrSnEYu5eGtNJzpqJTlLkWEn4uriI/VCTK02G8sJQhTgYHEA7XfBAIJ01MOl7yzNUSwoA1P b++i2Ve9e+ud6Xon1LOQ258= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk36LwFz12LKC; Thu, 4 Jun 2026 15:42:19 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id 0F0F340572; Thu, 4 Jun 2026 15:50:15 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:14 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:13 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 08/10] perf hisi-ptt: Add parsing of supported message types Date: Thu, 4 Jun 2026 15:50:03 +0800 Message-ID: <20260604075005.2219785-9-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) Content-Type: text/plain; charset="utf-8" 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 --- .../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/tool= s/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[] = =3D { [HISI_PTT_4DW_HEAD3] =3D "Header DW3", }; =20 +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 & 0x10) !=3D 0); +} + +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); +} + 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; }; =20 +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 =3D (pkt_type =3D=3D HISI_PTT_4DW_PKT) ? dw.dw0_4dw.format : + dw.dw0_8dw.format; + type =3D (pkt_type =3D=3D 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 =3D PERF_COLOR_BLUE; @@ -128,6 +191,8 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_bu= f *pkt_buf) union hisi_ptt_field_data dw; =20 dw.value =3D le32_to_cpu(*(__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.value); =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 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[] =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 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_un= used, pkt_buf.pos =3D 0; pkt_buf.pkt_type =3D hisi_ptt_check_packet_type(buf); 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 Mon Jun 8 09:49:04 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 B8F5D3E0741; Thu, 4 Jun 2026 07:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559420; cv=none; b=XuUHv22GGNzqzzW+TlNbe0b4UzuanPbDLBqco9jhsoMIF0v/iEWJQAUz/OeBQiSovPFbWDw+wBA1McGVbm+/qnarz9cLo0tnu52mBGvUgoEgB15WlZsfHQe7cJPGFFVYYcjK2cGjKz7H1aEPAESERA8Tjh7ypUP29isJpg6DjZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559420; c=relaxed/simple; bh=Pp2eFYuTRLDaoFJUVc4jhuqX0sBsanw7CwsKccjiS14=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MPC9mxVHOzduoaH4PvqOcdJTWUm1tgRnJCk9UoVAJZ/IROpi6QJkzbDCqkFU5x4EvH68CULjWC2nuH1CucmnS1BSEt7/PEucZPaOjR3fV1yeeyvXjE7rBs6xStuWU20rKWrROgXjA0dAmnRUUYw0vU5Ot9uhZmFMH8d3+9esWFo= 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=o38pD0R3; arc=none smtp.client-ip=113.46.200.226 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="o38pD0R3" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=UzphR8+an8ofSoVAEbaiJxbsv0Yp/2ccL+dSFmI1ONo=; b=o38pD0R30nKR6wN4Qoi76TNS9KE4m17u/NmM94Y4Noo23/L6JCyPeA4UBGM/0nIoQa0g7/eXd xkZILvwvAYSLGeJ2XaUy1Llf5rhX/kJNQcCJk5lnFbu9Mr/r5sfEXK+bj3bFHSUkjvF3wlgJdaz 2kg1gYf7in1uuhmlzWHI3dA= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4gWGk70HsRzKmZk; Thu, 4 Jun 2026 15:42:23 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 0882340572; Thu, 4 Jun 2026 15:50:16 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:15 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:14 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 09/10] perf hisi-ptt: Add field-level parsing for header DW2/DW3 Date: Thu, 4 Jun 2026 15:50:04 +0800 Message-ID: <20260604075005.2219785-10-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) Content-Type: text/plain; charset="utf-8" Add detailed field parsing for TLP header DW2 and DW3 based on the message type parsed from header DW0: - HEADER DW0: fields printed in 4DW format, printed as generic label in 8DW format for compatibility. - HEADER DW1: printed with the field name for both 4DW and 8DW formats. - HEADER DW2: fields printed for MWr/Msg/Atomic/IO TLPs, generic label for others. - HEADER DW3: fields printed for Completion and Configuration TLPs, generic label for others. This gives users more structured information when analysing PTT trace data. Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 161 +++++++++++++++++- 1 file changed, 152 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 59ab8ec3a03d..46f11d5719ac 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 @@ -38,6 +38,21 @@ * DW1 [ Header DW1 ] * DW2 [ Header DW2 ] * DW3 [ Header DW3 ] + * + * Header DW2 for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr is like: + * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ] + * |---------|----------------|----|---|--|-----------|----------| + * fields [Reserved][Request Segment][RSV][TV][T][Tag<13:10>][Header DW2] + * + * Header DW3 for CfgRd0/CfgWr0/CfgRd1/CfgWr1 is like: + * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:= 0 ] + * |---------|--------------------|----|---|--|-----------|------= ----| + * fields [Reserved][Destination Segment][DSV][TV][T][Tag<13:10>][Header= DW3] + * + * Header DW3 for Cpl/CplD/CplLk/CplDlk is like: + * bits [ 31:24 ][ 23:16 ][15][ 14:6 ][5][4]= [ 3:0 ] + * |--------------------|------------------|----|---------|--|---= |----------| + * fields [Destination Segment][Completer Segment][DSV][Reserved][TV][T]= [Tag<13:10>] */ =20 enum hisi_ptt_8dw_pkt_field_type { @@ -127,6 +142,45 @@ union hisi_ptt_field_data { uint32_t type : 5; uint32_t format : 3; } dw0_8dw; + /* + * Header DW2 for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr TLPs. + * Affects both 4DW and 8DW format. + */ + struct { + uint32_t header_dw2 : 16; + uint32_t tag : 4; + uint32_t t : 1; + uint32_t tv : 1; + uint32_t rsv : 1; + uint32_t request_segment : 8; + uint32_t reserved : 1; + } dw2_mixed; + /* + * Header DW3 for CfgRd0/CfgWr0/CfgRd1/CfgWr1 TLPs. + * Affects both 4DW and 8DW format. + */ + struct { + uint32_t header_dw3 : 16; + uint32_t tag : 4; + uint32_t t : 1; + uint32_t tv : 1; + uint32_t dsv : 1; + uint32_t destination_segment : 8; + uint32_t reserved : 1; + } dw3_cfg; + /* + * Header DW3 for Cpl/CplD/CplLk/CplDlk TLPs. + * Affects both 4DW and 8DW format. + */ + struct { + uint32_t tag : 4; + uint32_t t : 1; + uint32_t tv : 1; + uint32_t reserved : 9; + uint32_t dsv : 1; + uint32_t completer_segment : 8; + uint32_t destination_segment : 8; + } dw3_cpl; uint32_t value; }; =20 @@ -211,6 +265,85 @@ 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) +{ + const char *color =3D PERF_COLOR_BLUE; + union hisi_ptt_field_data dw; + + dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); + hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); + 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_HEAD1] : + hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD1]); + + pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; +} + +static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf) +{ + const char *color =3D PERF_COLOR_BLUE; + union hisi_ptt_field_data dw; + + dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); + hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); + + 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", dw.dw2_mixed.reserved, + "Request Segment", dw.dw2_mixed.request_segment, + "RSV", dw.dw2_mixed.rsv, "TV", dw.dw2_mixed.tv, + "T", dw.dw2_mixed.t, "Tag", dw.dw2_mixed.tag, + "Header DW2", dw.dw2_mixed.header_dw2); + 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; + union hisi_ptt_field_data dw; + + dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); + hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); + + 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", + dw.dw3_cpl.destination_segment, + "Completer Segment", dw.dw3_cpl.completer_segment, + "DSV", dw.dw3_cpl.dsv, + "Reserved", dw.dw3_cpl.reserved, + "TV", dw.dw3_cpl.tv, "T", dw.dw3_cpl.t, + "Tag", dw.dw3_cpl.tag); + 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", dw.dw3_cfg.reserved, + "Destination Segment", + dw.dw3_cfg.destination_segment, + "DSV", dw.dw3_cfg.dsv, "TV", dw.dw3_cfg.tv, + "T", dw.dw3_cfg.t, "Tag", dw.dw3_cfg.tag, + "Header DW3", dw.dw3_cfg.header_dw3); + 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; @@ -222,12 +355,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]; @@ -235,12 +380,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]; } --=20 2.33.0 From nobody Mon Jun 8 09:49:04 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 0613C3E2AAF; Thu, 4 Jun 2026 07:50:19 +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=1780559422; cv=none; b=WsikJgM6C6f6v7+9NpkPSgU9Uv/gg0l9FLCV88Z01vvkqc5eaBSg16WoJFnS7P24wJqybcUBKyNS7kD9Gdw/J8v5nVM/jsV1brJ2fy4TSbuzuI304bWVKhgThfQ91Sk13F8Hz/lJjysX4nbGbJFjQ3CWlkIjF8Zu6Kn2f7e25II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780559422; c=relaxed/simple; bh=COY0rQh1n/z30TdSnCBlGi7MVXfydWJg2Nu79+etnls=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nVmkpboE+S7XW1sYaXsYsO+jZS7fi+sdjiexXHYlT51I/RnYIQRkem2tAQpGWQXO8q3Z8pnRvpbHd6YGwqE5/yRyyH9VYxJS2gyr+Pb2H0ggC0ALA9sXHwhmTyWfuTdGdAbp8SEAGveBh2sDpn6f4lc6nnaNbYKhrx6cDhIY3lk= 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=VZZQkXS0; 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="VZZQkXS0" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=ur/yZcP+gQolt10/5ytaDnmV+aVSxeNTztYqMmNoF6s=; b=VZZQkXS0QVBcVuvHS46pfizVwh8dj5udvMMPe6TbHWMy+vMtvMUfuOM5uwnh37TWHbgt4JbKs 76YWDQAbqnatFkn0X16NJO218qnfao5nMHESe14sm5Sr41hvU7kbEQyAGNSdaUX8EV+tCHDbtVQ cLa1MNHGCoDjSkob9z9UyEM= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4gWGkC4v8Lz1cyPc; Thu, 4 Jun 2026 15:42:27 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 00DAB40561; Thu, 4 Jun 2026 15:50:17 +0800 (CST) Received: from kwepemn200012.china.huawei.com (7.202.194.135) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:16 +0800 Received: from huawei.com (10.50.163.32) by kwepemn200012.china.huawei.com (7.202.194.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 15:50:15 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH 10/10] perf hisi-ptt: Add decoder version compatibility Date: Thu, 4 Jun 2026 15:50:05 +0800 Message-ID: <20260604075005.2219785-11-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260604075005.2219785-1-liusizhe5@huawei.com> References: <20260604075005.2219785-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: kwepems200001.china.huawei.com (7.221.188.67) To kwepemn200012.china.huawei.com (7.202.194.135) Content-Type: text/plain; charset="utf-8" The hisi_ptt packet decoder now performs detailed field-level parsing of TLP header DW2 and DW3 based on the message type classified from DW0 (added in the previous patches). However, trace data recorded with older versions of the tool does not contain the information needed for this detailed parsing, and should continue to use the generic field-name-only output. Introduce a version field (V1/V2) in the auxtrace info record to distinguish between the two data formats: - V1 (legacy): auxtrace priv contains only PMU type. DW2 and DW3 are printed with generic field names only, no message-type-based field decoding. - V2 (current): auxtrace priv contains PMU type and version. DW2 and DW3 are decoded according to the TLP message type (MWr, Msg, Atomic, IO, CPL, Cfg) with detailed field names. At recording time, set the version to HISI_PTT_DECODER_V2 in the auxtrace info. At decoding time, determine the version from the priv data size and the version field: - If priv_size >=3D V2, read the version from priv[1]. - If priv_size < V2, assume V1 for backward compatibility. - If version is unknown (future), warn and decode auxtrace as v2. Also add the version to the dump output alongside the PMU type. Adjust hisi_ptt_pkt_size position to adapt to compilation. Signed-off-by: Sizhe Liu --- tools/perf/arch/arm64/util/hisi-ptt.c | 2 ++ .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 35 ++++++++++++------- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 8 ++--- tools/perf/util/hisi-ptt.c | 23 ++++++++---- tools/perf/util/hisi-ptt.h | 4 ++- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/tools/perf/arch/arm64/util/hisi-ptt.c b/tools/perf/arch/arm64/= util/hisi-ptt.c index fe457fd58c9e..9a28f96b8e57 100644 --- a/tools/perf/arch/arm64/util/hisi-ptt.c +++ b/tools/perf/arch/arm64/util/hisi-ptt.c @@ -24,6 +24,7 @@ #include "../../../util/record.h" #include "../../../util/session.h" #include "../../../util/tsc.h" +#include "../../../util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.h" =20 #define KiB(x) ((x) * 1024) #define MiB(x) ((x) * 1024 * 1024) @@ -58,6 +59,7 @@ static int hisi_ptt_info_fill(struct auxtrace_record *itr, =20 auxtrace_info->type =3D PERF_AUXTRACE_HISI_PTT; auxtrace_info->priv[0] =3D hisi_ptt_pmu->type; + auxtrace_info->priv[1] =3D HISI_PTT_DECODER_V2; =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 46f11d5719ac..0611f121431c 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,6 +75,11 @@ enum hisi_ptt_4dw_pkt_field_type { HISI_PTT_4DW_TYPE_MAX }; =20 +static int hisi_ptt_pkt_size[] =3D { + [HISI_PTT_4DW_PKT] =3D 16, + [HISI_PTT_8DW_PKT] =3D 32, +}; + static const char * const hisi_ptt_8dw_pkt_field_name[] =3D { [HISI_PTT_8DW_CHK_AND_RSV0] =3D "CHK & RSV0", [HISI_PTT_8DW_PREFIX] =3D "Prefix", @@ -284,14 +289,19 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_= buf *pkt_buf) { const char *color =3D PERF_COLOR_BLUE; union hisi_ptt_field_data dw; + 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]; =20 dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); =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->version < HISI_PTT_DECODER_V2) + 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", dw.dw2_mixed.reserved, @@ -300,10 +310,7 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_b= uf *pkt_buf) "T", dw.dw2_mixed.t, "Tag", dw.dw2_mixed.tag, "Header DW2", dw.dw2_mixed.header_dw2); 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; } @@ -312,11 +319,16 @@ static void hisi_ptt_print_head3(struct hisi_ptt_pkt_= buf *pkt_buf) { const char *color =3D PERF_COLOR_BLUE; union hisi_ptt_field_data dw; + 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]; =20 dw.value =3D le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos)); hisi_ptt_print_raw_record(pkt_buf->pos, dw.value); =20 - if (pkt_buf->pkt_msg_type =3D=3D HISI_PTT_PKT_TYPE_CPL) + if (pkt_buf->version < HISI_PTT_DECODER_V2) + 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", @@ -336,10 +348,7 @@ static void hisi_ptt_print_head3(struct hisi_ptt_pkt_b= uf *pkt_buf) "T", dw.dw3_cfg.t, "Tag", dw.dw3_cfg.tag, "Header DW3", dw.dw3_cfg.header_dw3); 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 3fdad34fe400..d1bffab449d4 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 @@ -14,6 +14,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_DECODER_V1 1 +#define HISI_PTT_DECODER_V2 2 =20 enum hisi_ptt_pkt_type { HISI_PTT_4DW_PKT, @@ -21,11 +23,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) */ @@ -43,6 +40,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; + uint32_t version; }; =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 e321f393601b..4f52cfb4e190 100644 --- a/tools/perf/util/hisi-ptt.c +++ b/tools/perf/util/hisi-ptt.c @@ -33,6 +33,12 @@ struct hisi_ptt { struct perf_session *session; struct machine *machine; u32 pmu_type; + u32 version; +}; + +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) @@ -45,8 +51,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; @@ -56,6 +61,7 @@ static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_un= used, pkt_buf.pkt_type =3D hisi_ptt_check_packet_type(buf); 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; + pkt_buf.version =3D ptt->version; color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n", pkt_buf.len); =20 @@ -146,12 +152,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(__u64 type, u32 version) { if (!dump_trace) return; =20 fprintf(stdout, " PMU Type %" PRId64 "\n", (s64) type); + fprintf(stdout, " Tracer Version %" PRIu32 "\n", version); } =20 int hisi_ptt_process_auxtrace_info(union perf_event *event, @@ -159,10 +166,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_V1 + 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) @@ -172,7 +182,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->version =3D priv_size >=3D HISI_PTT_AUXTRACE_PRIV_SIZE_V2 ? + (u32)auxtrace_info->priv[1] : HISI_PTT_DECODER_V1; ptt->auxtrace.process_event =3D hisi_ptt_process_event; ptt->auxtrace.process_auxtrace_event =3D hisi_ptt_process_auxtrace_event; ptt->auxtrace.flush_events =3D hisi_ptt_flush; @@ -181,7 +192,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(auxtrace_info->priv[0], ptt->version); =20 return 0; } diff --git a/tools/perf/util/hisi-ptt.h b/tools/perf/util/hisi-ptt.h index 2db9b4056214..67b051980113 100644 --- a/tools/perf/util/hisi-ptt.h +++ b/tools/perf/util/hisi-ptt.h @@ -8,7 +8,9 @@ #define INCLUDE__PERF_HISI_PTT_H__ =20 #define HISI_PTT_PMU_NAME "hisi_ptt" -#define HISI_PTT_AUXTRACE_PRIV_SIZE sizeof(u64) +#define HISI_PTT_AUXTRACE_PRIV_SIZE_V1 sizeof(u64) +#define HISI_PTT_AUXTRACE_PRIV_SIZE_V2 (2 * sizeof(u64)) +#define HISI_PTT_AUXTRACE_PRIV_SIZE HISI_PTT_AUXTRACE_PRIV_SIZE_V2 =20 struct auxtrace_record *hisi_ptt_recording_init(int *err, struct perf_pmu *hisi_ptt_pmu); --=20 2.33.0