From nobody Fri Sep 25 20:47:58 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 2C863551997; Tue, 8 Sep 2026 14:05:23 +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=1788876335; cv=none; b=MGo0HHlQKPNBCDfiWo+2wO72Qo91RpiinNNqkoeTrzEFpLVK6tsckOw+pkT0KbeqLKoU3OKPvOxV+IM48s8GCxgjbTqHgiiPaZb91Lb9bwpwhxLJxYGZjnN/MtMpR6R+o38u+kLOg1ceadec7PRQctelN3Zsxs206Y1TaufkWCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876335; c=relaxed/simple; bh=ZkSa5qlS66ITQsGD0bm2TaiLYkgiuBXR4HO+CvEheds=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nFEK25sY7k849IW4Cz0Ycsf8c4m3AhkvkM8MhKWc4osvmer93CJyH6w3j8JxClrCr3wZ9a090NaUjmlQ7NZSfVE64Z2HAk/QH8vURbUQ9Yor59I1yltTngzFDF3v0XAJFWXzLX0Xs/SQgomYRoh+y3Gb4blmcNpL4lmNnn2HLSc= 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.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="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.140]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hfQQy14Czzcb46; Tue, 8 Sep 2026 21:54:18 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 2F3FB203C8; Tue, 8 Sep 2026 22:05:15 +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; Tue, 8 Sep 2026 22:05:12 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 1/8] perf hisi-ptt: Abstract trace data buf and offset Date: Tue, 8 Sep 2026 22:05:02 +0800 Message-ID: <20260908140509.2485649-2-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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 Fri Sep 25 20:47:58 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 8ECD654B1BC; Tue, 8 Sep 2026 14:05:25 +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=1788876338; cv=none; b=L2Qnj03cf3pp5qRa55TM0HVV6Q2JfIB/tlNiGUF7mq4peNl8B3GAYYJo5nb5cjmnZj/gJ6CvDL9KYS9v9Ks+kSytrL7VvOTg/dbsSCPHF02RpYv75S5DM6X4Dmbc1pv5GA2hQtZrmh2gMmOpJhmTUecT1p9dGmlUL/fyy7pp9OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876338; c=relaxed/simple; bh=uv31mMGJY8917i0D41i+PSbwTCNxtolCmItMY7GqkH0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q2gtsmcaju5hnD339+WMM7E3oNuhTL+fwxTGxsuHSDnP2/+CioazLO6a2UQ0b/zm+nJf0RhK+uMLQQMYDH0JK0Q6MMEcaWlY19aNi+hWP2NY6/fHPxWQn/Vyks28HYRdB4KJOrkxdVGl/lXkFgjfRcfAbcTT05PlJclVi6SRKYE= 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.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="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.163.0]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4hfQR204Zsz1prlJ; Tue, 8 Sep 2026 21:54:22 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 691AE4057A; Tue, 8 Sep 2026 22:05:17 +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; Tue, 8 Sep 2026 22:05:14 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 2/8] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Date: Tue, 8 Sep 2026 22:05:03 +0800 Message-ID: <20260908140509.2485649-3-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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 Fri Sep 25 20:47:58 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 2C2EF55198A; Tue, 8 Sep 2026 14:05:23 +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=1788876335; cv=none; b=O/SRMcqDwG5I0MMqZkmqEMHJzpl2vih4yOL31NseaovDCHqcdufr3pZxyYp8/Cgtr4BA0xh2sEN9WqkPrZyuIUQhal0Hpx2ObG5xkxezrwi72/bz59VMvuUVzvY2ZSUwTTHYX54BEyapiednc/jKlYVYZ7YuEmvPlDzdUmgxUso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876335; c=relaxed/simple; bh=11TxVI+3RBj+EqHgRjR2LbaLhcvV0cslORERYKWeuco=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WfeisWPAjvmp/JUT5zuBmlZ7WAhgdQyomMFD/2V6zwR9JqmIcoMNHI32Rp3KMB33gQNU8+Ci6icgjcufVUUvUGyfioY4M2BSTHheomGpZAKhoK9tHYLvpURo/hcBtn2wWvbvmPfKbzRReHHOcPpcNVaPS0mMCa5H2dqhThT2+Dc= 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.163.104]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hfQR244NMzcb49; Tue, 8 Sep 2026 21:54:22 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 988F24056E; Tue, 8 Sep 2026 22:05:19 +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; Tue, 8 Sep 2026 22:05:17 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 3/8] perf hisi-ptt: Extract the raw data printing part Date: Tue, 8 Sep 2026 22:05:04 +0800 Message-ID: <20260908140509.2485649-4-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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 Fri Sep 25 20:47:58 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 B9C285448BD; Tue, 8 Sep 2026 14:05:34 +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=1788876344; cv=none; b=LrwAN5E6BemAtcAApBl6/XB/AFjWOc1tYyNKIwRH7znugWAX5QQe8Qh6QzSbC97Svs0iLRnUdrvjga0erC/Z4pONEttHrL515NZzDYWSMjzYk7anqFqNe1SB49zkotNqlEDoVxDPZ+vdpXUqAN+lFFF9FbXYmbAcLPlQRESwDpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876344; c=relaxed/simple; bh=szcD0O0Lfg6pYgcK/czU3XzUQZ3ONYu2wuySJYZ2NP8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q6qDEiy44h5mMr0kNykpUZWkpi/Vayj6IGXTheAF4ZaqZzxq+XZWpZuSu5pm8hUwK+kE9ar8/9pWvqtJ4DZ2LWRxpF9hb49WtxA1tIEe1cami1PIOEvRtZozZC/YqtBwJFArjAtn9VWczyZixpWReyK3ZMtc65gH7p0cPmLZ+gM= 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.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="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.162.92]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4hfQQr1RZHznTVd; Tue, 8 Sep 2026 21:54:12 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id C86EE40586; Tue, 8 Sep 2026 22:05:21 +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; Tue, 8 Sep 2026 22:05:19 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 4/8] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Date: Tue, 8 Sep 2026 22:05:05 +0800 Message-ID: <20260908140509.2485649-5-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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 Fri Sep 25 20:47:58 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 D1D3655295D; Tue, 8 Sep 2026 14:05:31 +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=1788876342; cv=none; b=mcl7rTwK1T2XSG/wT5CZkluLe/t9fAk5sBo7+T93kvMEWiTECDCqkelA6U1NDtz13rreMJt4jJIZmJdSXXB7dBRdgCborK0lt0QlvQZsq/82Blw9IzMB9/VPXufduVsDhS11cINFx8iyAsnTTgQgdWw22ZuwjdDqiqiHtwUgNhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876342; c=relaxed/simple; bh=oNagAoiLPeAHyFczTOdhq3KY2IDlLHS+ZRGsujd9c+A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bOFBX9o2BjreHZIy5npvuvwATaqLVndd1R3FmYviDXGmo5sTRXQQulImbNOJ+2c7+7tlzqxASOMWhj0duRe/Yw2/xNnY4MeJOK7vRSIIBYBP0+RMOqKaTDW2E0qf1mCOkl8UstH0N5lwLQoE8RX3Fp5CWc/84cJJIJQwB8qpMOw= 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=KnNaAEdw; 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="KnNaAEdw" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=pd9x46nrmAOaC2BjKspVDuYVO1rQ3lmlYo9Ncu9f5iw=; b=KnNaAEdws/1ozk/JlA0HrBb4EKhznmfvIy2+XmntI8y+3YaFztipNOLb3wVX2SS9sDILDYyky kKIaZlApFm125MuxT2WuB5nc03Ih055e36P7Lta7L4Z6qnH1O3E/0Q9ETWlxpm7XKXrH8rEGU0G 5BIKROtvtGgOI7AqBhCDutE= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4hfQRB6H2pz1cyPY; Tue, 8 Sep 2026 21:54:30 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 0BFCA40563; Tue, 8 Sep 2026 22:05:24 +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; Tue, 8 Sep 2026 22:05:21 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 5/8] perf hisi-ptt: Add parsing of supported message types and proto length Date: Tue, 8 Sep 2026 22:05:06 +0800 Message-ID: <20260908140509.2485649-6-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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: - MRd (Non-posted Memory Read request) - MWr (Posted Memory Write request) - DMWr (Posted Deferrable Memory write request) - Msg (Posted Message request) - Atom (Non-Posted AtomicOP 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 DW1, DW2 and DW3 printing. Classify protocol defined header length by Format field, according to PCIe r6.4 sec 2.2.1.1. Reviewed-by: Yushan Wang Signed-off-by: Sizhe Liu --- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.c | 89 +++++++++++++++++++ .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 40 ++++++++- tools/perf/util/hisi-ptt.c | 1 + 3 files changed, 126 insertions(+), 4 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 00bd9309df68..c9515676ba5c 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,94 @@ 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_mrd_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0 || format =3D=3D 0x1) && (type =3D=3D 0); +} + +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_dmwr_tlp(uint32_t format, uint32_t type) +{ + return (format =3D=3D 0x2 || format =3D=3D 0x3) && (type =3D=3D 0x1b); +} + +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 format, uint32_t type) +{ + if (hisi_ptt_is_mrd_tlp(format, type)) + return HISI_PTT_PKT_TYPE_MRD; + else if (hisi_ptt_is_mwr_tlp(format, type)) + return HISI_PTT_PKT_TYPE_MWR; + else if (hisi_ptt_is_dmwr_tlp(format, type)) + return HISI_PTT_PKT_TYPE_DMWR; + 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 int hisi_ptt_parse_pkt_header_proto_len(uint32_t format) +{ + if (format & 0x1) + return HISI_PTT_4DW_HEADER_PROTO_LEN; + + return HISI_PTT_3DW_HEADER_PROTO_LEN; +} + +static void hisi_ptt_parse_pkt_info(struct hisi_ptt_pkt_buf *pkt_buf, + uint32_t dw) +{ + uint32_t format, type; + + format =3D (pkt_buf->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_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT) ? + FIELD_GET(HISI_PTT_HEAD0_4DW_TYPE, dw) : + FIELD_GET(HISI_PTT_HEAD0_8DW_TYPE, dw); + + pkt_buf->pkt_msg_type =3D hisi_ptt_parse_pkt_msg_type(format, type); + pkt_buf->proto_len =3D hisi_ptt_parse_pkt_header_proto_len(format); +} + static void hisi_ptt_print_raw_record(size_t offset, uint32_t value) { const char *color =3D PERF_COLOR_BLUE; @@ -114,6 +202,7 @@ 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); + hisi_ptt_parse_pkt_info(pkt_buf, dw); 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..f02ba29dfe00 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,15 +7,18 @@ #ifndef INCLUDE__HISI_PTT_PKT_DECODER_H__ #define INCLUDE__HISI_PTT_PKT_DECODER_H__ =20 +#include #include #include #include #include =20 -#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_LENGTH 4 +#define HISI_PTT_8DW_CHECK_MASK GENMASK_U32(31, 11) +#define HISI_PTT_IS_8DW_PKT GENMASK_U32(31, 11) +#define HISI_PTT_MAX_SPACE_LEN 10 +#define HISI_PTT_FIELD_LENGTH 4 +#define HISI_PTT_3DW_HEADER_PROTO_LEN 3 +#define HISI_PTT_4DW_HEADER_PROTO_LEN 4 =20 /* Header DW0 fields for 4DW format */ #define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0) @@ -27,6 +30,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 +45,36 @@ static int hisi_ptt_pkt_size[] =3D { [HISI_PTT_8DW_PKT] =3D 32, }; =20 +enum hisi_ptt_pkt_msg_type { + /* Types do not support analysis */ + HISI_PTT_PKT_TYPE_UNKNOWN, + /* NP-(Memory Read requset: MRd) */ + HISI_PTT_PKT_TYPE_MRD, + /* P-(Memory write request: MWr) */ + HISI_PTT_PKT_TYPE_MWR, + /* P-(Deferrable Memory write request: DMWr) */ + HISI_PTT_PKT_TYPE_DMWR, + /* P-(Message request: Msg, MsgD) */ + HISI_PTT_PKT_TYPE_MSG, + /* NP-(AtomicOP request: FetchAdd, Swap, CAS) */ + HISI_PTT_PKT_TYPE_ATOM, + /* NP-(I/O request: IORd, IOWr) */ + HISI_PTT_PKT_TYPE_IO, + /* NP-(Configuration request: CfgRd0, CfgWr0, CfgRd1, CfgWr1) */ + HISI_PTT_PKT_TYPE_CFG, + /* CPL-(Completion: Cpl, CplD) */ + HISI_PTT_PKT_TYPE_CPL, + /* Type max in enumeration*/ + 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; + size_t proto_len; }; =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 Fri Sep 25 20:47:58 2026 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (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 6DD0454B1C8; Tue, 8 Sep 2026 14:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876351; cv=none; b=RBhhuAd/gbShfUG9HRPhsuOeFeAG5CvGfCIzZi04W7IS499wjh6viNOGUEJcaQiEYv5Rd7Gq0xZtL3/U80/PimL7/m7yE0olR0fK9NGDW0F90wDrH4Ld4qnagkxEbQWs0JygGlOyjLnHD0imnBd0UW1kwY72YGK/CbTPmzsm/f8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876351; c=relaxed/simple; bh=tSY5lNtVSw6p8ePg7zmHWZJCwiirVE5tq8scnE5IqzU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kk0/ZKLFTf3HGw2cueRGOID2ZPQhXts4qglMnXu6wQfkxWnyfs+OOL0HCmzmyO+OIkCTCzirvnHlwwrZbYP1/1pSmeW1XYGLT6W1aNoOSZ3A5mqppC9+SYNQ/uE+YZ46MO2GKIXxt0427+uQAOkv6vFd6ag6XwLpTOLhb+fq7Y4= 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=vyssBvWB; arc=none smtp.client-ip=113.46.200.221 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="vyssBvWB" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Mj4oUaNTXUKRZc4TY/6jCY6Ial69B+rhkh2dGvFv3xE=; b=vyssBvWBAaVrreqCYSQJ9G/JHXv5LyFNd9doaOUO5KWwcYH3rMk2VlDTilUVgt27GRqThHLC+ wX5RUcYDRw25CWCX1AVxCd4oukXXvX8ZvHawgbRZZjs1u7/QwsO58u45ZTOl0hX//LnyLwb0+AC udQfRqRzRzT9PPb42zYDF3I= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4hfQRG5BRPzRhVP; Tue, 8 Sep 2026 21:54:34 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 4051140561; Tue, 8 Sep 2026 22:05:26 +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; Tue, 8 Sep 2026 22:05:23 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 6/8] perf hisi-ptt: Add field-level parsing for header DW0/DW1/DW2/DW3 Date: Tue, 8 Sep 2026 22:05:07 +0800 Message-ID: <20260908140509.2485649-7-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 whupemo200004.china.huawei.com (7.152.184.18) Content-Type: text/plain; charset="utf-8" Add field-level parsing of Header DW0, DW1, DW2 and DW3 of the TLP, separating the layout for different requests. The message type parsed in the previous patch is used to select the corresponding field layout. 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 | 386 +++++++++++++++++- .../hisi-ptt-decoder/hisi-ptt-pkt-decoder.h | 194 ++++++++- 2 files changed, 545 insertions(+), 35 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 c9515676ba5c..482a50c2e9f5 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 @@ -196,9 +196,42 @@ 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_4dw_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %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)); +} + +static void hisi_ptt_print_head0_8dw_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s = %x %s %x %s %x\n", + "Format", + FIELD_GET(HISI_PTT_HEAD0_8DW_FORMAT, dw), + "Type", FIELD_GET(HISI_PTT_HEAD0_8DW_TYPE, dw), + "T9", FIELD_GET(HISI_PTT_HEAD0_8DW_T9, dw), + "TC", FIELD_GET(HISI_PTT_HEAD0_8DW_TC, dw), + "T8", FIELD_GET(HISI_PTT_HEAD0_8DW_T8, dw), + "A2", FIELD_GET(HISI_PTT_HEAD0_8DW_A2, dw), + "LN", FIELD_GET(HISI_PTT_HEAD0_8DW_LN, dw), + "TH", FIELD_GET(HISI_PTT_HEAD0_8DW_TH, dw), + "TD", FIELD_GET(HISI_PTT_HEAD0_8DW_TD, dw), + "EP", FIELD_GET(HISI_PTT_HEAD0_8DW_EP, dw), + "Attr<1:0>", FIELD_GET(HISI_PTT_HEAD0_8DW_ATTR_1_0, dw), + "AT", FIELD_GET(HISI_PTT_HEAD0_8DW_AT, dw), + "Length", FIELD_GET(HISI_PTT_HEAD0_8DW_LEN, dw)); +} + static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf) { - const char *color =3D PERF_COLOR_BLUE; uint32_t dw; =20 dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); @@ -206,24 +239,323 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt= _buf *pkt_buf) hisi_ptt_print_raw_record(pkt_buf->pos, dw); =20 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)); + hisi_ptt_print_head0_4dw_fields(dw); + else if (pkt_buf->pkt_type =3D=3D HISI_PTT_8DW_PKT) + hisi_ptt_print_head0_8dw_fields(dw); else - color_fprintf(stdout, color, " %s\n", + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0]); =20 pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } =20 +static void hisi_ptt_print_head1_ar64_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x\n", + "Requester ID", FIELD_GET(HISI_PTT_HEAD1_AR64_REQ_ID, dw), + "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_AR64_TAG_7_0, dw), + "Last DW BE", + FIELD_GET(HISI_PTT_HEAD1_AR64_LAST_DW_BE, dw), + "First DW BE", + FIELD_GET(HISI_PTT_HEAD1_AR64_FIRST_DW_BE, dw)); +} + +static void hisi_ptt_print_head1_ar32_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x\n", + "Requester ID", FIELD_GET(HISI_PTT_HEAD1_AR32_REQ_ID, dw), + "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_AR32_TAG_7_0, dw), + "Last DW BE", + FIELD_GET(HISI_PTT_HEAD1_AR32_LAST_DW_BE, dw), + "First DW BE", + FIELD_GET(HISI_PTT_HEAD1_AR32_FIRST_DW_BE, dw)); +} + +static void hisi_ptt_print_head1_cfg_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x\n", + "Requester ID", FIELD_GET(HISI_PTT_HEAD1_CFG_REQ_ID, dw), + "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_CFG_TAG_7_0, dw), + "Last DW BE", + FIELD_GET(HISI_PTT_HEAD1_CFG_LAST_DW_BE, dw), + "First DW BE", + FIELD_GET(HISI_PTT_HEAD1_CFG_FIRST_DW_BE, dw)); +} + +static void hisi_ptt_print_head1_cpl_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x\n", + "Completer ID", FIELD_GET(HISI_PTT_HEAD1_CPL_COM_ID, dw), + "Cpl Status", FIELD_GET(HISI_PTT_HEAD1_CPL_STA, dw), + "BCM", FIELD_GET(HISI_PTT_HEAD1_CPL_BCM, dw), + "Byte Count", FIELD_GET(HISI_PTT_HEAD1_CPL_BYTE_CNT, dw)); +} + +static void hisi_ptt_print_head1_msg_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x\n", + "Requester ID", FIELD_GET(HISI_PTT_HEAD1_MSG_REQ_ID, dw), + "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD1_MSG_TAG_7_0, dw), + "Message Code", FIELD_GET(HISI_PTT_HEAD1_MSG_CODE, dw)); +} + +static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf) +{ + uint32_t dw; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + switch (pkt_buf->pkt_msg_type) { + case HISI_PTT_PKT_TYPE_MRD: + case HISI_PTT_PKT_TYPE_MWR: + case HISI_PTT_PKT_TYPE_DMWR: + case HISI_PTT_PKT_TYPE_ATOM: + case HISI_PTT_PKT_TYPE_IO: + if (pkt_buf->proto_len =3D=3D HISI_PTT_4DW_HEADER_PROTO_LEN) + hisi_ptt_print_head1_ar64_fields(dw); + else + hisi_ptt_print_head1_ar32_fields(dw); + break; + case HISI_PTT_PKT_TYPE_CFG: + hisi_ptt_print_head1_cfg_fields(dw); + break; + case HISI_PTT_PKT_TYPE_CPL: + hisi_ptt_print_head1_cpl_fields(dw); + break; + case HISI_PTT_PKT_TYPE_MSG: + hisi_ptt_print_head1_msg_fields(dw); + break; + case HISI_PTT_PKT_TYPE_UNKNOWN: + case HISI_PTT_PKT_TYPE_MAX: + default: + color_fprintf(stdout, PERF_COLOR_BLUE, " %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]); + break; + } + + pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; +} + +static void hisi_ptt_print_head2_ar64_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", + "RSV2", FIELD_GET(HISI_PTT_HEAD2_AR64_RSV2, dw), + "Request Segment", + FIELD_GET(HISI_PTT_HEAD2_AR64_REQ_SEG, dw), + "RSV1", FIELD_GET(HISI_PTT_HEAD2_AR64_RSV1, dw), + "TV", FIELD_GET(HISI_PTT_HEAD2_AR64_TV, dw), + "T", FIELD_GET(HISI_PTT_HEAD2_AR64_T, dw), + "Tag<13:10>", + FIELD_GET(HISI_PTT_HEAD2_AR64_TAG_13_10, dw), + "Addr<47:32>", + FIELD_GET(HISI_PTT_HEAD2_AR64_ADDR_47_32, dw)); +} + +static void hisi_ptt_print_head2_ar32_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x\n", + "Addr<31:2>", + FIELD_GET(HISI_PTT_HEAD2_AR32_ADDR_31_2, dw), + "PH<1:0>", FIELD_GET(HISI_PTT_HEAD2_AR32_PH_1_0, dw)); +} + +static void hisi_ptt_print_head2_io_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x\n", + "Addr<31:2>", + FIELD_GET(HISI_PTT_HEAD2_AR32_ADDR_31_2, dw), + "Reserved", FIELD_GET(HISI_PTT_HEAD2_AR32_IO_RSV, dw)); +} + +static void hisi_ptt_print_head2_cfg_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x %s %x\n", + "Destination ID", + FIELD_GET(HISI_PTT_HEAD2_CFG_DST_ID, dw), + "RSV2", FIELD_GET(HISI_PTT_HEAD2_CFG_RSV2, dw), + "Ext Reg Num", + FIELD_GET(HISI_PTT_HEAD2_CFG_REG_NUM_EXT, dw), + "Register Number", + FIELD_GET(HISI_PTT_HEAD2_CFG_REG_NUM, dw), + "RSV1", FIELD_GET(HISI_PTT_HEAD2_CFG_RSV1, dw)); +} + +static void hisi_ptt_print_head2_cpl_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x\n", + "Requester ID", FIELD_GET(HISI_PTT_HEAD2_CPL_REQ_ID, dw), + "Tag<7:0>", FIELD_GET(HISI_PTT_HEAD2_CPL_TAG_7_0, dw), + "Reserved", FIELD_GET(HISI_PTT_HEAD2_CPL_RSV, dw), + "Lower Address", + FIELD_GET(HISI_PTT_HEAD2_CPL_LO_ADDR, dw)); +} + +static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf) +{ + uint32_t dw; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + switch (pkt_buf->pkt_msg_type) { + case HISI_PTT_PKT_TYPE_MRD: + case HISI_PTT_PKT_TYPE_MWR: + case HISI_PTT_PKT_TYPE_DMWR: + case HISI_PTT_PKT_TYPE_ATOM: + if (pkt_buf->proto_len =3D=3D HISI_PTT_4DW_HEADER_PROTO_LEN) + hisi_ptt_print_head2_ar64_fields(dw); + else + hisi_ptt_print_head2_ar32_fields(dw); + break; + case HISI_PTT_PKT_TYPE_IO: + hisi_ptt_print_head2_io_fields(dw); + break; + case HISI_PTT_PKT_TYPE_CFG: + hisi_ptt_print_head2_cfg_fields(dw); + break; + case HISI_PTT_PKT_TYPE_CPL: + hisi_ptt_print_head2_cpl_fields(dw); + break; + case HISI_PTT_PKT_TYPE_MSG: + case HISI_PTT_PKT_TYPE_UNKNOWN: + case HISI_PTT_PKT_TYPE_MAX: + default: + color_fprintf(stdout, PERF_COLOR_BLUE, " %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]); + break; + } + + pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; +} + +static void hisi_ptt_print_head3_ar64_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x\n", + "Addr<31:2>", + FIELD_GET(HISI_PTT_HEAD3_AR64_ADDR_31_2, dw), + "PH<1:0>", FIELD_GET(HISI_PTT_HEAD3_AR64_PH_1_0, dw)); +} + +static void hisi_ptt_print_head3_ar32_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s %x %s = %x\n", + "Request Segment", + FIELD_GET(HISI_PTT_HEAD3_AR32_REQ_SEG, dw), + "ST<15:8>", FIELD_GET(HISI_PTT_HEAD3_AR32_ST_15_8, dw), + "RSV2", FIELD_GET(HISI_PTT_HEAD3_AR32_RSV2, dw), + "HV", FIELD_GET(HISI_PTT_HEAD3_AR32_HV, dw), + "AMA", FIELD_GET(HISI_PTT_HEAD3_AR32_AMA, dw), + "AV", FIELD_GET(HISI_PTT_HEAD3_AR32_AV, dw), + "FM", FIELD_GET(HISI_PTT_HEAD3_AR32_FM, dw), + "RSV1", FIELD_GET(HISI_PTT_HEAD3_AR32_RSV1, dw), + "TV", FIELD_GET(HISI_PTT_HEAD3_AR32_TV, dw), + "T", FIELD_GET(HISI_PTT_HEAD3_AR32_T, dw), + "Tag<13:10>", + FIELD_GET(HISI_PTT_HEAD3_AR32_TAG_13_10, dw)); +} + +static void hisi_ptt_print_head3_io_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", + "Request Segment", + FIELD_GET(HISI_PTT_HEAD3_AR32_REQ_SEG, dw), + "RSV2", FIELD_GET(HISI_PTT_HEAD3_AR32_IO_RSV2, dw), + "FM", FIELD_GET(HISI_PTT_HEAD3_AR32_FM, dw), + "RSV1", FIELD_GET(HISI_PTT_HEAD3_AR32_RSV1, dw), + "TV", FIELD_GET(HISI_PTT_HEAD3_AR32_TV, dw), + "T", FIELD_GET(HISI_PTT_HEAD3_AR32_T, dw), + "Tag<13:10>", + FIELD_GET(HISI_PTT_HEAD3_AR32_TAG_13_10, dw)); +} + +static void hisi_ptt_print_head3_cfg_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n", + "RSV2", FIELD_GET(HISI_PTT_HEAD3_CFG_RSV2, 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<13:10>", FIELD_GET(HISI_PTT_HEAD3_CFG_TAG_13_10, dw), + "RSV1", FIELD_GET(HISI_PTT_HEAD3_CFG_RSV1, dw)); +} + +static void hisi_ptt_print_head3_cpl_fields(uint32_t dw) +{ + color_fprintf(stdout, PERF_COLOR_BLUE, + " %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_COM_SEG, dw), + "DSV", FIELD_GET(HISI_PTT_HEAD3_CPL_DSV, dw), + "Reserved", FIELD_GET(HISI_PTT_HEAD3_CPL_RSV, dw), + "TV", FIELD_GET(HISI_PTT_HEAD3_CPL_TV, dw), + "T", FIELD_GET(HISI_PTT_HEAD3_CPL_T, dw), + "Tag<13:10>", + FIELD_GET(HISI_PTT_HEAD3_CPL_TAG_13_10, dw)); +} + +static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf) +{ + uint32_t dw; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + switch (pkt_buf->pkt_msg_type) { + case HISI_PTT_PKT_TYPE_MRD: + case HISI_PTT_PKT_TYPE_MWR: + case HISI_PTT_PKT_TYPE_DMWR: + case HISI_PTT_PKT_TYPE_ATOM: + if (pkt_buf->proto_len =3D=3D HISI_PTT_4DW_HEADER_PROTO_LEN) + hisi_ptt_print_head3_ar64_fields(dw); + else + hisi_ptt_print_head3_ar32_fields(dw); + break; + case HISI_PTT_PKT_TYPE_IO: + hisi_ptt_print_head3_io_fields(dw); + break; + case HISI_PTT_PKT_TYPE_CFG: + hisi_ptt_print_head3_cfg_fields(dw); + break; + case HISI_PTT_PKT_TYPE_CPL: + hisi_ptt_print_head3_cpl_fields(dw); + break; + case HISI_PTT_PKT_TYPE_MSG: + case HISI_PTT_PKT_TYPE_UNKNOWN: + case HISI_PTT_PKT_TYPE_MAX: + default: + color_fprintf(stdout, PERF_COLOR_BLUE, " %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]); + break; + } + + pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; +} + static int hisi_ptt_8dw_pkt_desc(struct hisi_ptt_pkt_buf *pkt_buf) { int i; @@ -235,12 +567,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]; @@ -248,12 +592,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 f02ba29dfe00..5f71cfdcb7a7 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 @@ -20,19 +20,187 @@ #define HISI_PTT_3DW_HEADER_PROTO_LEN 3 #define HISI_PTT_4DW_HEADER_PROTO_LEN 4 =20 -/* Header DW0 fields for 4DW format */ -#define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0) -#define HISI_PTT_HEAD0_4DW_LEN GENMASK_U32(20, 11) -#define HISI_PTT_HEAD0_4DW_SO BIT_U32(21) -#define HISI_PTT_HEAD0_4DW_TH BIT_U32(22) -#define HISI_PTT_HEAD0_4DW_T8 BIT_U32(23) -#define HISI_PTT_HEAD0_4DW_T9 BIT_U32(24) -#define HISI_PTT_HEAD0_4DW_TYPE GENMASK_U32(29, 25) -#define HISI_PTT_HEAD0_4DW_FORMAT GENMASK_U32(31, 30) - -/* 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) +/* Hisi PTT Header DW0 fields for 4DW format + * + * bits [31:30] [ 29:25 ][24][23][22][21][ 20:11 ][ 10:0 ] + * |-----|---------|---|---|---|---|-------------|-------------| + * DW0 [ Fmt ][ Type ][T9][T8][TH][SO][ Length ][ Time ] + */ +#define HISI_PTT_HEAD0_4DW_TIME GENMASK_U32(10, 0) +#define HISI_PTT_HEAD0_4DW_LEN GENMASK_U32(20, 11) +#define HISI_PTT_HEAD0_4DW_SO BIT_U32(21) +#define HISI_PTT_HEAD0_4DW_TH BIT_U32(22) +#define HISI_PTT_HEAD0_4DW_T8 BIT_U32(23) +#define HISI_PTT_HEAD0_4DW_T9 BIT_U32(24) +#define HISI_PTT_HEAD0_4DW_TYPE GENMASK_U32(29, 25) +#define HISI_PTT_HEAD0_4DW_FORMAT GENMASK_U32(31, 30) + +/* Hisi PTT Header DW0 fields for 8DW format + * + * bits [31:29][28:24][23][22:20][19][18][17][16][15][14][ 13:12 ][11:10= ][ 9:0 ] + * |------|------|---|------|---|---|---|---|---|---|----------|-----= -|-----------| + * DW0 [ Fmt ][Type] [T9][ TC ] [T8][A2][LN][TH][TD][EP][ATTR<1:0>][ AT ]= [ Length ] + */ +#define HISI_PTT_HEAD0_8DW_LEN GENMASK_U32(9, 0) +#define HISI_PTT_HEAD0_8DW_AT GENMASK_U32(11, 10) +#define HISI_PTT_HEAD0_8DW_ATTR_1_0 GENMASK_U32(13, 12) +#define HISI_PTT_HEAD0_8DW_EP BIT_U32(14) +#define HISI_PTT_HEAD0_8DW_TD BIT_U32(15) +#define HISI_PTT_HEAD0_8DW_TH BIT_U32(16) +#define HISI_PTT_HEAD0_8DW_LN BIT_U32(17) +#define HISI_PTT_HEAD0_8DW_A2 BIT_U32(18) +#define HISI_PTT_HEAD0_8DW_T8 BIT_U32(19) +#define HISI_PTT_HEAD0_8DW_TC GENMASK_U32(22, 20) +#define HISI_PTT_HEAD0_8DW_T9 BIT_U32(23) +#define HISI_PTT_HEAD0_8DW_TYPE GENMASK_U32(28, 24) +#define HISI_PTT_HEAD0_8DW_FORMAT GENMASK_U32(31, 29) + +/* Hisi PTT Header DW1/DW2/DW3 fields for 64-bit Address-Based Routing TLPs + * Used with Memory rd/wr DMWr and AtomicOp Requests. + * + * bits [ 31:16 ][ 15:8 ][ 7:4 ][ 3:0 ] + * |-------------|---------|-----------|-----------| + * DW1 [Requester ID][Tag<7:0>][Last DW BE][First DW BE] + * + * bits [ 31 ][ 30:23 ][ 22 ][21][20][ 19:16 ][ 15:0 = ] + * |---------|----------------|-----|---|--|-----------|-------------= -| + * DW2 [ RSV2 ][Request Segment][RSV1][TV][T][Tag<13:10>][Address<47:3= 2>] + * + * bits [ 31:2 ][ 1:0 ] + * |--------------|-------| + * DW3 [Address<31:2>][PH<1:0>] + */ +#define HISI_PTT_HEAD1_AR64_REQ_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD1_AR64_TAG_7_0 GENMASK_U32(15, 8) +#define HISI_PTT_HEAD1_AR64_LAST_DW_BE GENMASK_U32(7, 4) +#define HISI_PTT_HEAD1_AR64_FIRST_DW_BE GENMASK_U32(3, 0) +#define HISI_PTT_HEAD2_AR64_RSV2 BIT_U32(31) +#define HISI_PTT_HEAD2_AR64_REQ_SEG GENMASK_U32(30, 23) +#define HISI_PTT_HEAD2_AR64_RSV1 BIT_U32(22) +#define HISI_PTT_HEAD2_AR64_TV BIT_U32(21) +#define HISI_PTT_HEAD2_AR64_T BIT_U32(20) +#define HISI_PTT_HEAD2_AR64_TAG_13_10 GENMASK_U32(19, 16) +#define HISI_PTT_HEAD2_AR64_ADDR_47_32 GENMASK_U32(15, 0) +#define HISI_PTT_HEAD3_AR64_ADDR_31_2 GENMASK_U32(31, 2) +#define HISI_PTT_HEAD3_AR64_PH_1_0 GENMASK_U32(1, 0) + +/* Hisi PTT Header DW1/DW2/DW3 fields for 32-bit Address-Based Routing TLPs + * Used with Memory rd/wr DMWr, AtomicOp and I/O Requests. + * + * bits [ 31:16 ][ 15:8 ][ 7:4 ][ 3:0 ] + * |-------------|---------|-----------|-----------| + * DW1 [Requester ID][Tag<7:0>][Last DW BE][First DW BE] + * + * For Memory rd/wr DMWr and AtomicOp Requests + * bits [ 31:2 ][ 1:0 ] + * |--------------|-------| + * DW2 [Address<31:2>][PH<1:0>] + * + * For I/O Transactions + * bits [ 31:2 ][ 1:0 ] + * |--------------|--------| + * DW2 [Address<31:2>][Reserved] + * + * For Memory rd/wr DMWr and AtomicOp Requests + * bits [ 31:24 ][ 23:16 ][ 15:14 ][13:12][11:9] [8 ][7 ][ 6 ][= 5 ][4][ 3:0 ] + * |-----------------|---------|--------|------|------|---|---|-----|= ---|--|----------| + * DW3 [Request Segments][ST<15:8>][ RSV2 ][ HV ][ AMA ][AV][FM][RSV1][= TV][T][Tag<13:10>] + * + * For I/O Transactions + * bits [ 31:24 ][ 23:8 ][7 ][ 6 ][5 ][4][ 3:0 ] + * |-----------------|---------|---|-----|---|--|----------| + * DW3 [Request Segments][ RSV2 ][FM][RSV1][TV][T][Tag<13:10>] + */ +#define HISI_PTT_HEAD1_AR32_REQ_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD1_AR32_TAG_7_0 GENMASK_U32(15, 8) +#define HISI_PTT_HEAD1_AR32_LAST_DW_BE GENMASK_U32(7, 4) +#define HISI_PTT_HEAD1_AR32_FIRST_DW_BE GENMASK_U32(3, 0) +#define HISI_PTT_HEAD2_AR32_ADDR_31_2 GENMASK_U32(31, 2) +#define HISI_PTT_HEAD2_AR32_PH_1_0 GENMASK_U32(1, 0) +#define HISI_PTT_HEAD2_AR32_IO_RSV GENMASK_U32(1, 0) +#define HISI_PTT_HEAD3_AR32_REQ_SEG GENMASK_U32(31, 24) +#define HISI_PTT_HEAD3_AR32_ST_15_8 GENMASK_U32(23, 16) +#define HISI_PTT_HEAD3_AR32_RSV2 GENMASK_U32(15, 14) +#define HISI_PTT_HEAD3_AR32_HV GENMASK_U32(13, 12) +#define HISI_PTT_HEAD3_AR32_AMA GENMASK_U32(11, 9) +#define HISI_PTT_HEAD3_AR32_AV BIT_U32(8) +#define HISI_PTT_HEAD3_AR32_FM BIT_U32(7) +#define HISI_PTT_HEAD3_AR32_RSV1 BIT_U32(6) +#define HISI_PTT_HEAD3_AR32_TV BIT_U32(5) +#define HISI_PTT_HEAD3_AR32_T BIT_U32(4) +#define HISI_PTT_HEAD3_AR32_TAG_13_10 GENMASK_U32(3, 0) +#define HISI_PTT_HEAD3_AR32_IO_RSV2 GENMASK_U32(23, 8) + +/* Hisi PTT Header DW1/DW2/DW3 fields for Configuration Requests + * + * bits [ 31:16 ][ 15:8 ][ 7:4 ][ 3:0 ] + * |-------------|---------|-----------|-----------| + * DW1 [Requester ID][Tag<7:0>][Last DW BE][First DW BE] + * + * bits [ 31:16 ][ 15:12 ][ 11:8 ][ 7:2 ][ 1:0] + * |--------------|---------|------------|----------------|----| + * DW2 [Destination ID][ RSV2 ][Ext Reg Num][Register Number][RSV1] + * + * bits [ 31 ][ 30:23 ][22][21][20][ 19:16 ][ 15:0 ] + * |---------|--------------------|----|---|--|-----------|----------| + * DW3 [ RSV2 ][Destination Segment][DSV][TV][T][Tag<13:10>][ RSV1 ] + */ +#define HISI_PTT_HEAD1_CFG_REQ_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD1_CFG_TAG_7_0 GENMASK_U32(15, 8) +#define HISI_PTT_HEAD1_CFG_LAST_DW_BE GENMASK_U32(7, 4) +#define HISI_PTT_HEAD1_CFG_FIRST_DW_BE GENMASK_U32(3, 0) +#define HISI_PTT_HEAD2_CFG_DST_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD2_CFG_RSV2 GENMASK_U32(15, 12) +#define HISI_PTT_HEAD2_CFG_REG_NUM_EXT GENMASK_U32(11, 8) +#define HISI_PTT_HEAD2_CFG_REG_NUM GENMASK_U32(7, 2) +#define HISI_PTT_HEAD2_CFG_RSV1 GENMASK_U32(1, 0) +#define HISI_PTT_HEAD3_CFG_RSV2 BIT_U32(31) +#define HISI_PTT_HEAD3_CFG_DST_SEG GENMASK_U32(30, 23) +#define HISI_PTT_HEAD3_CFG_DSV BIT_U32(22) +#define HISI_PTT_HEAD3_CFG_TV BIT_U32(21) +#define HISI_PTT_HEAD3_CFG_T BIT_U32(20) +#define HISI_PTT_HEAD3_CFG_TAG_13_10 GENMASK_U32(19, 16) +#define HISI_PTT_HEAD3_CFG_RSV1 GENMASK_U32(15, 0) + +/* Hisi PTT Header DW1/DW2/DW3 fields for Completion TLPs + * + * bits [ 31:16 ][ 15:13 ][12 ][ 11:0 ] + * |-------------|-----------|----|----------| + * DW1 [Completer ID][Cpl Status][BCM][Byte Count] + * + * bits [ 31:16 ][ 15:8 ][ 7 ][ 6:0 ] + * |-------------|---------|----|-------------| + * DW2 [Requester ID][Tag<7:0>][RSV][Lower Address] + * + * bits [ 31:24 ][ 23:16 ][15 ][ 14:6][5][4 ][ 3:0= ] + * |--------------------|------------------|----|------|--|---|------= ----| + * DW3 [Destination Segment][Completer Segment][DSV][ RSV ][TV][T][Tag<13= :10>] + */ +#define HISI_PTT_HEAD1_CPL_COM_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD1_CPL_STA GENMASK_U32(15, 13) +#define HISI_PTT_HEAD1_CPL_BCM BIT_U32(12) +#define HISI_PTT_HEAD1_CPL_BYTE_CNT GENMASK_U32(11, 0) +#define HISI_PTT_HEAD2_CPL_REQ_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD2_CPL_TAG_7_0 GENMASK_U32(15, 8) +#define HISI_PTT_HEAD2_CPL_RSV BIT_U32(7) +#define HISI_PTT_HEAD2_CPL_LO_ADDR GENMASK_U32(6, 0) +#define HISI_PTT_HEAD3_CPL_DST_SEG GENMASK_U32(31, 24) +#define HISI_PTT_HEAD3_CPL_COM_SEG GENMASK_U32(23, 16) +#define HISI_PTT_HEAD3_CPL_DSV BIT_U32(15) +#define HISI_PTT_HEAD3_CPL_RSV GENMASK_U32(14, 6) +#define HISI_PTT_HEAD3_CPL_TV BIT_U32(5) +#define HISI_PTT_HEAD3_CPL_T BIT_U32(4) +#define HISI_PTT_HEAD3_CPL_TAG_13_10 GENMASK_U32(3, 0) + +/* Hisi PTT Header DW1 fields for Message Requests + * + * bits [ 31:16 ][ 15:8 ][ 7:0 ] + * |-------------|---------|------------| + * DW1 [Requester ID][Tag<7:0>][Message Code] + */ +#define HISI_PTT_HEAD1_MSG_REQ_ID GENMASK_U32(31, 16) +#define HISI_PTT_HEAD1_MSG_TAG_7_0 GENMASK_U32(15, 8) +#define HISI_PTT_HEAD1_MSG_CODE GENMASK_U32(7, 0) =20 enum hisi_ptt_pkt_type { HISI_PTT_4DW_PKT, --=20 2.33.0 From nobody Fri Sep 25 20:47:58 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 6CB9654EED1; Tue, 8 Sep 2026 14:05:41 +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=1788876358; cv=none; b=M5LpOdNqbqPynZj3/FLbNczxhuTblj5msciyNQvb02JM3AhRYAYzQ+jRY3iMnARpsjcgkAbVkV/hiSesSh4aWOBrXfEA44IaOrUXgcsQeWFGRUPbIuxEhYjQfKV0BXbtrr5a+60nenNuLZbL5vOHfgRt7BbOO3TuIFGXUnf/U+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876358; c=relaxed/simple; bh=W1VwhXPhIyRDCSnSemNsnoMkcKwfZtTpoqwIoeFGE7I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RlfFLLK/bzxiFsGcF4lO254hgYSqR3AEscXdmC9aZTmEgN8zXa3jSD38NWNfpU4zmZC1CcMqtuCD4ikF5LGNxVmQlDp6d+fgqSdUtfHiotoZVJd/2dvi8xbDRVjGI/muBIxGSc0rxYZuwyHrtzEmoTtKQb1g8gzZNUJYx2K1zLk= 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=H0ZBxixl; 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="H0ZBxixl" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=gWvItwcvRDtpm+4cG8lep+8yTi+6ko6t7VY0PWBGT+0=; b=H0ZBxixlC1kQVrJnFuXCxTX1f1Kj/EDEHa/l4aeuejxp4i9IEXX5YV27QvwFhaxfE4sdxKNdW hD1Mn7INPGPNbO7aSoK0Xd4QlWhGiU0mnqdBHj+ICvlPrc4hIvwiR2+qDCDAepemrbd6zlJfdBa 00ewsFWP1kD1iSMZMaebZEo= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4hfQRB6r8yzKmT6; Tue, 8 Sep 2026 21:54:30 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id 7112540563; Tue, 8 Sep 2026 22:05:28 +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; Tue, 8 Sep 2026 22:05:25 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 7/8] hwtracing: hisi_ptt: Add pattern PMU config for trace format selection Date: Tue, 8 Sep 2026 22:05:08 +0800 Message-ID: <20260908140509.2485649-8-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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 | 26 ++++++++++++++++++++++++-- drivers/hwtracing/ptt/hisi_ptt.c | 25 ++++++++++++++++++++++++- drivers/hwtracing/ptt/hisi_ptt.h | 4 ++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/Documentation/trace/hisi-ptt.rst b/Documentation/trace/hisi-pt= t.rst index f6a2655f99e5..a70719386159 100644 --- a/Documentation/trace/hisi-ptt.rst +++ b/Documentation/trace/hisi-ptt.rst @@ -255,7 +255,29 @@ 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 + DW0 (in 8DW format), DW1, DW2 and DW3 are printed with generic field n= ames, + and no message-type-based field decoding. Consider using legacy trace = format + when the current PCIe link generation is not higher than PCIe 6.0. +- 4'b0001: trace format v1 + DW0, DW1, DW2 and DW3 are decoded according to the TLP message type (M= Rd, + MWr, DMWr, Msg, AtomicOP, I/O, Cpl, Cfg) with detailed field names. + It is recommended to use trace format v1 when the current PCIe link + generation is higher than 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 +296,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..c1636676c8c8 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:4; }; =20 /* --=20 2.33.0 From nobody Fri Sep 25 20:47:58 2026 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 6A53C2BFC8F; Tue, 8 Sep 2026 14:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876358; cv=none; b=Xq32zLhZOusOScPcDebRUp4lE+taTlPucFtgguhYiVZWQvH1PvHq+WuEEAz95m9aPfq7Ux0Kijkr1AEx6JKEfVHsPFEuScUPd301WNR4Mt9yh7Mj4aucwU+MHZd6IjQEuIGART6Ww1fuw7IsoX3Cy9/lCGtKeZio6uMM9X93LnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788876358; c=relaxed/simple; bh=A1FRc8WGhF6hii3FFWLLJSWWiRBHYBOUPMnCs/FOESQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BI0IuDnihiRqF6JeNbcOJX2kGod3Y4Wm56tplZhSyXDE4f3wAW5SzNot1tknoevbr/GeSjerzMJsi2htgsAAhhc4b3bQGaBRTWny4h6WFX/qyiato2DSfdE/19Ed7SMe6eVsQ8v1hWfWYw7vRlDmaPLSvP2ZHrWqn+Ppf/H8P8g= 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=TKCoVZhk; arc=none smtp.client-ip=113.46.200.225 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="TKCoVZhk" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=JiNSKeamnhE8f/a70MV3yVqNUJqh2LyF6XzFZXRiNZc=; b=TKCoVZhkWEk0AXX5jqoWpcCHvJx7VLiuQUdjPYDI59P/hMC7fC5g487XtPVXbRsxLTikXd7eI 21bhFQSZ7kIXqODZMYSYYX4d0jMpialgLRfgKzJUIYJnqLgqND8x1yqDKGByejm6gmBLKJ1LjsF Rlaf2DRxQSPOApzJugEkRN8= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4hfQRJ54VXz1K97G; Tue, 8 Sep 2026 21:54:36 +0800 (CST) Received: from whupemo200004.china.huawei.com (unknown [7.152.184.18]) by mail.maildlp.com (Postfix) with ESMTPS id A8E9A40572; Tue, 8 Sep 2026 22:05:30 +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; Tue, 8 Sep 2026 22:05:28 +0800 From: Sizhe Liu To: , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v4 8/8] perf hisi-ptt: Pass pattern version to decoder for compatibility Date: Tue, 8 Sep 2026 22:05:09 +0800 Message-ID: <20260908140509.2485649-9-liusizhe5@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260908140509.2485649-1-liusizhe5@huawei.com> References: <20260908140509.2485649-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 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 | 123 ++++++++++++------ .../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, 133 insertions(+), 53 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 482a50c2e9f5..62b98d98b2e9 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_mrd_tlp(uint32_t format, uint32_t type) { @@ -230,21 +235,36 @@ static void hisi_ptt_print_head0_8dw_fields(uint32_t = dw) "Length", FIELD_GET(HISI_PTT_HEAD0_8DW_LEN, dw)); } =20 +static void hisi_ptt_print_head0_fields_v1(struct hisi_ptt_pkt_buf *pkt_bu= f, + uint32_t dw, const char *desc) +{ + if (pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT) + hisi_ptt_print_head0_4dw_fields(dw); + else if (pkt_buf->pkt_type =3D=3D HISI_PTT_8DW_PKT) + hisi_ptt_print_head0_8dw_fields(dw); + else + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc); +} + static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf) { + const char *desc =3D pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT ? + hisi_ptt_4dw_pkt_field_name[HISI_PTT_4DW_HEAD0] : + hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0]; uint32_t dw; =20 dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); hisi_ptt_parse_pkt_info(pkt_buf, dw); hisi_ptt_print_raw_record(pkt_buf->pos, dw); =20 - if (pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT) - hisi_ptt_print_head0_4dw_fields(dw); - else if (pkt_buf->pkt_type =3D=3D HISI_PTT_8DW_PKT) - hisi_ptt_print_head0_8dw_fields(dw); + if (pkt_buf->pattern < HISI_PTT_PATTERN_V1) { + if (pkt_buf->pkt_type =3D=3D HISI_PTT_4DW_PKT) + hisi_ptt_print_head0_4dw_fields(dw); + else + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc); + } else - color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", - hisi_ptt_8dw_pkt_field_name[HISI_PTT_8DW_HEAD0]); + hisi_ptt_print_head0_fields_v1(pkt_buf, dw, desc); =20 pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } @@ -304,13 +324,9 @@ static void hisi_ptt_print_head1_msg_fields(uint32_t d= w) "Message Code", FIELD_GET(HISI_PTT_HEAD1_MSG_CODE, dw)); } =20 -static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf) +static void hisi_ptt_print_head1_fields_v1(struct hisi_ptt_pkt_buf *pkt_bu= f, + uint32_t dw, const char *desc) { - uint32_t dw; - - dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); - hisi_ptt_print_raw_record(pkt_buf->pos, dw); - switch (pkt_buf->pkt_msg_type) { case HISI_PTT_PKT_TYPE_MRD: case HISI_PTT_PKT_TYPE_MWR: @@ -334,12 +350,25 @@ static void hisi_ptt_print_head1(struct hisi_ptt_pkt_= buf *pkt_buf) case HISI_PTT_PKT_TYPE_UNKNOWN: case HISI_PTT_PKT_TYPE_MAX: default: - color_fprintf(stdout, PERF_COLOR_BLUE, " %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]); + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc); break; } +} + +static void hisi_ptt_print_head1(struct hisi_ptt_pkt_buf *pkt_buf) +{ + const char *desc =3D 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]; + 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->pattern < HISI_PTT_PATTERN_V1) + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc); + else + hisi_ptt_print_head1_fields_v1(pkt_buf, dw, desc); =20 pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } @@ -403,13 +432,9 @@ static void hisi_ptt_print_head2_cpl_fields(uint32_t d= w) FIELD_GET(HISI_PTT_HEAD2_CPL_LO_ADDR, dw)); } =20 -static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf) +static void hisi_ptt_print_head2_fields_v1(struct hisi_ptt_pkt_buf *pkt_bu= f, + uint32_t dw, const char *desc) { - uint32_t dw; - - dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); - hisi_ptt_print_raw_record(pkt_buf->pos, dw); - switch (pkt_buf->pkt_msg_type) { case HISI_PTT_PKT_TYPE_MRD: case HISI_PTT_PKT_TYPE_MWR: @@ -433,12 +458,25 @@ static void hisi_ptt_print_head2(struct hisi_ptt_pkt_= buf *pkt_buf) case HISI_PTT_PKT_TYPE_UNKNOWN: case HISI_PTT_PKT_TYPE_MAX: default: - color_fprintf(stdout, PERF_COLOR_BLUE, " %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, PERF_COLOR_BLUE, " %s\n", desc); break; } +} + +static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf) +{ + 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; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + if (pkt_buf->pattern < HISI_PTT_PATTERN_V1) + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc); + else + hisi_ptt_print_head2_fields_v1(pkt_buf, dw, desc); =20 pkt_buf->pos +=3D HISI_PTT_FIELD_LENGTH; } @@ -516,13 +554,9 @@ static void hisi_ptt_print_head3_cpl_fields(uint32_t d= w) FIELD_GET(HISI_PTT_HEAD3_CPL_TAG_13_10, dw)); } =20 -static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf) +static void hisi_ptt_print_head3_fields_v1(struct hisi_ptt_pkt_buf *pkt_bu= f, + uint32_t dw, const char *desc) { - uint32_t dw; - - dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); - hisi_ptt_print_raw_record(pkt_buf->pos, dw); - switch (pkt_buf->pkt_msg_type) { case HISI_PTT_PKT_TYPE_MRD: case HISI_PTT_PKT_TYPE_MWR: @@ -546,12 +580,25 @@ static void hisi_ptt_print_head3(struct hisi_ptt_pkt_= buf *pkt_buf) case HISI_PTT_PKT_TYPE_UNKNOWN: case HISI_PTT_PKT_TYPE_MAX: default: - color_fprintf(stdout, PERF_COLOR_BLUE, " %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, PERF_COLOR_BLUE, " %s\n", desc); break; } +} + +static void hisi_ptt_print_head3(struct hisi_ptt_pkt_buf *pkt_buf) +{ + 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; + + dw =3D get_unaligned_le32(pkt_buf->buf + pkt_buf->pos); + hisi_ptt_print_raw_record(pkt_buf->pos, dw); + + if (pkt_buf->pattern < HISI_PTT_PATTERN_V1) + color_fprintf(stdout, PERF_COLOR_BLUE, " %s\n", desc); + else + hisi_ptt_print_head3_fields_v1(pkt_buf, dw, 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 5f71cfdcb7a7..f17ee6b549ca 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 @@ -19,6 +19,8 @@ #define HISI_PTT_FIELD_LENGTH 4 #define HISI_PTT_3DW_HEADER_PROTO_LEN 3 #define HISI_PTT_4DW_HEADER_PROTO_LEN 4 +#define HISI_PTT_PATTERN_LEGACY 0 +#define HISI_PTT_PATTERN_V1 1 =20 /* Hisi PTT Header DW0 fields for 4DW format * @@ -208,11 +210,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 { /* Types do not support analysis */ HISI_PTT_PKT_TYPE_UNKNOWN, @@ -243,6 +240,7 @@ struct hisi_ptt_pkt_buf { enum hisi_ptt_pkt_type pkt_type; enum hisi_ptt_pkt_msg_type pkt_msg_type; size_t proto_len; + 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