lkml.org 
[lkml]   [2020]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v6 08/21] perf arm-spe: Add new function arm_spe_pkt_desc_addr()
Date
This patch moves out the address parsing code from arm_spe_pkt_desc()
and uses the new introduced function arm_spe_pkt_desc_addr() to process
address packet.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
.../arm-spe-decoder/arm-spe-pkt-decoder.c | 50 ++++++++++++-------
1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index 30d6c987c287..ae68cd788e33 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -274,10 +274,39 @@ static int arm_spe_pkt_snprintf(int *err, char **buf_p, size_t *blen,
return ret;
}

+static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
+ char *buf, size_t buf_len)
+{
+ int ns, el, idx = packet->index;
+ u64 payload = packet->payload;
+ int err = 0;
+
+ switch (idx) {
+ case 0:
+ case 1:
+ ns = !!(packet->payload & NS_FLAG);
+ el = (packet->payload & EL_FLAG) >> 61;
+ payload &= ~(0xffULL << 56);
+ return arm_spe_pkt_snprintf(&err, &buf, &buf_len,
+ "%s 0x%llx el%d ns=%d",
+ (idx == 1) ? "TGT" : "PC", payload, el, ns);
+ case 2:
+ return arm_spe_pkt_snprintf(&err, &buf, &buf_len,
+ "VA 0x%llx", payload);
+ case 3:
+ ns = !!(packet->payload & NS_FLAG);
+ payload &= ~(0xffULL << 56);
+ return arm_spe_pkt_snprintf(&err, &buf, &buf_len,
+ "PA 0x%llx ns=%d", payload, ns);
+ default:
+ return 0;
+ }
+}
+
int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
size_t buf_len)
{
- int ns, el, idx = packet->index;
+ int idx = packet->index;
unsigned long long payload = packet->payload;
const char *name = arm_spe_pkt_name(packet->type);
size_t blen = buf_len;
@@ -356,24 +385,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
case ARM_SPE_TIMESTAMP:
return arm_spe_pkt_snprintf(&err, &buf, &blen, "%s %lld", name, payload);
case ARM_SPE_ADDRESS:
- switch (idx) {
- case 0:
- case 1: ns = !!(packet->payload & NS_FLAG);
- el = (packet->payload & EL_FLAG) >> 61;
- payload &= ~(0xffULL << 56);
- return arm_spe_pkt_snprintf(&err, &buf, &blen,
- "%s 0x%llx el%d ns=%d",
- (idx == 1) ? "TGT" : "PC", payload, el, ns);
- case 2:
- return arm_spe_pkt_snprintf(&err, &buf, &blen,
- "VA 0x%llx", payload);
- case 3: ns = !!(packet->payload & NS_FLAG);
- payload &= ~(0xffULL << 56);
- return arm_spe_pkt_snprintf(&err, &buf, &blen,
- "PA 0x%llx ns=%d", payload, ns);
- default:
- return 0;
- }
+ return arm_spe_pkt_desc_addr(packet, buf, buf_len);
case ARM_SPE_CONTEXT:
return arm_spe_pkt_snprintf(&err, &buf, &blen, "%s 0x%lx el%d",
name, (unsigned long)payload, idx + 1);
--
2.17.1
\
 
 \ /
  Last update: 2020-10-30 03:59    [W:0.267 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site