Messages in this thread Patch in this message | | | From | Leo Yan <> | Subject | [PATCH v3 11/20] perf arm-spe: Add new function arm_spe_pkt_desc_counter() | Date | Thu, 22 Oct 2020 15:58:07 +0100 |
| |
This patch moves out the counter packet parsing code from arm_spe_pkt_desc() to the new function arm_spe_pkt_desc_counter().
Signed-off-by: Leo Yan <leo.yan@linaro.org> --- .../arm-spe-decoder/arm-spe-pkt-decoder.c | 64 +++++++++++-------- 1 file changed, 37 insertions(+), 27 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 1fc07c693640..023bcc9be3cc 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 @@ -293,6 +293,42 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet, } } +static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet, + char *buf, size_t buf_len) +{ + u64 payload = packet->payload; + const char *name = arm_spe_pkt_name(packet->type); + size_t blen = buf_len; + int ret; + + ret = arm_spe_pkt_snprintf(&buf, &blen, "%s %d ", name, + (unsigned short)payload); + if (ret < 0) + return ret; + + switch (packet->index) { + case 0: + ret = arm_spe_pkt_snprintf(&buf, &blen, "TOT"); + if (ret < 0) + return ret; + break; + case 1: + ret = arm_spe_pkt_snprintf(&buf, &blen, "ISSUE"); + if (ret < 0) + return ret; + break; + case 2: + ret = arm_spe_pkt_snprintf(&buf, &blen, "XLAT"); + if (ret < 0) + return ret; + break; + default: + break; + } + + return buf_len - blen; +} + int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, size_t buf_len) { @@ -435,33 +471,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, return arm_spe_pkt_snprintf(&buf, &blen, "%s 0x%lx el%d", name, (unsigned long)payload, idx + 1); case ARM_SPE_COUNTER: - ret = arm_spe_pkt_snprintf(&buf, &blen, "%s %d ", name, - (unsigned short)payload); - if (ret < 0) - return ret; - - switch (idx) { - case 0: - ret = arm_spe_pkt_snprintf(&buf, &blen, "TOT"); - if (ret < 0) - return ret; - break; - case 1: - ret = arm_spe_pkt_snprintf(&buf, &blen, "ISSUE"); - if (ret < 0) - return ret; - break; - case 2: - ret = arm_spe_pkt_snprintf(&buf, &blen, "XLAT"); - if (ret < 0) - return ret; - break; - default: - break; - } - - return buf_len - blen; - + return arm_spe_pkt_desc_counter(packet, buf, buf_len); default: break; } -- 2.17.1
| |