Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp151815pxb; Tue, 10 Nov 2020 23:26:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCO7cjppVSPhyDFFoCgsUD2FEXE/P8moPcfXGn99bRKdyd1bKnqrod3Tsrd5F3HHWaTNk2 X-Received: by 2002:a17:906:aecd:: with SMTP id me13mr15928439ejb.433.1605079596584; Tue, 10 Nov 2020 23:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605079596; cv=none; d=google.com; s=arc-20160816; b=r6e+rOg8HYE+NfB9wBozvWdgZXOwtd/kg7f9YVy11QqB96jzXqfL5O2QNbcAxub9uQ tIJCb1XBBglCci2GMCuLJttt8tNLmi7fEFmKXPDHRiQoksHoaK5cADY4XeuZZCyB0qXo s8MTExCeRTKc4GbzTmjVfSalkwFJ9ZHdYjm2aJ5/NETfY6eEcjefZrAUr4u3CqK+8Vom AJSuUJ7Lt+j/mekZIOGt6IcPbuR5CqFgRusS389dRAw8IeeQmoUeaJeDaFX9SDxM8KbI TpdgWMuHNqbhky3CTU5nrL0mGaKvzWBqaFgwLHJh8I8l2/8QwXzTWAhOMLRRKuhTxhBd xfsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Cwi+Q/uFcEJF2+kNznSruYlRv2WNCgUDUKyB3fZNRAA=; b=NJINT4f6K+90kTBko7R8dmqLKm4y670WNRtF5gSjRtv6Q+tHUUN2XdynPOM3r2ZC05 IgezLjNn5iQsiyp+vbVUYHsXAdNa2vaDOvrWG5ki7vdeGsY/WyiJEN6O011EPqSFqKaQ xs9rEqwozaB/xCttmiMIFfBUO8x43BUko/YBxSB2B0V5MxsZovOy9JTIdNtOEo3CZEcy La+Q7eyr8+Y/mWqNn2SqS8UJXZ0qR8+L4LwBhtqHQv8qj/VhAEt0t4g1km8ZKicO34Iz J03xOR0IAfExAgEzee3+g/XMlEFKuulghCB9Luoi5k3WO6CBMr/HRWjNe5naO8JfT5Cy E1VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hLU0o4ed; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t9si909506edw.355.2020.11.10.23.26.13; Tue, 10 Nov 2020 23:26:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hLU0o4ed; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbgKKHVk (ORCPT + 99 others); Wed, 11 Nov 2020 02:21:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgKKHOJ (ORCPT ); Wed, 11 Nov 2020 02:14:09 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF12C061A47 for ; Tue, 10 Nov 2020 23:13:13 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id x13so1056848pfa.9 for ; Tue, 10 Nov 2020 23:13:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cwi+Q/uFcEJF2+kNznSruYlRv2WNCgUDUKyB3fZNRAA=; b=hLU0o4ed1PabH9Fg/g5G3+q7sbwj3i3wb5aroBHq2lpeZpw01jFYB5wOffbIxsMPMp 1q7a15Kww3WUusmq9cfrL4z1iLVwyX9dzpLFeli1FG0dXD03xjvOa9yEI6iFWMqcEg9g cK85WMsZRCnwui0zy8gFuPwB8fmyKmVKkgVz5dcJ67wa0IHP1CVaf7/of1eOhlfcaAfZ kCG6bICbjqo6HHgE1H9i9x0TXqz8o9Bc0gbH0/f6VZKmYDp8stWIU3mjEIz4NWOzocnk Le4QVy8pFVnQvAp2f8302IQqR4xDTib8bKUOzDs/tEVoz/DKVjEzQFQnCmnwOLIMc46L GgLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cwi+Q/uFcEJF2+kNznSruYlRv2WNCgUDUKyB3fZNRAA=; b=IsRqjXN/MtpDlF8UHgL1jxaZXahkRxUiSv896Lo24y72diuYVaQU4paeLTBhxUExpb ESqNMhKoNXhvBFtkoB2ncsBIlIT38oRkDsYPDjYj6sbK5s4Zpso6lyPbUxTW/7Bxys2H Sw/VZK3rAQOydkatI9idH6aJopbGVdRlTq9Y91oQwiVn/L7OzpnKgmcLBMjEVcFtP70K KxHfpVaYrs6n7pFxCYAYk59iBl9jxNOq3ihg3eB5ZoFjCgSEOdqe2RJU6+Qiz+pSwZON HFsy1NOyG3ccz3Qansah1Q58LXht5iqJZrsa/Fxjv36UiaWThREFk1eyBqK4Ja/zmE6R 5OQw== X-Gm-Message-State: AOAM531Ah+HHppvrI8D6nnlsKZdN8Zfj5BPPlbRjg2Zaxu07Ybuc6Cee 0QCIe3ndeO+eedgtwJ9zdCq34A== X-Received: by 2002:a63:5f17:: with SMTP id t23mr20936551pgb.190.1605078792639; Tue, 10 Nov 2020 23:13:12 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id v126sm1305060pfb.137.2020.11.10.23.13.11 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Nov 2020 23:13:12 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Andre Przywara , Dave Martin , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Al Grant , Wei Li , John Garry , Will Deacon , Mathieu Poirier , linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v8 14/22] perf arm-spe: Refactor counter packet handling Date: Wed, 11 Nov 2020 15:11:41 +0800 Message-Id: <20201111071149.815-15-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111071149.815-1-leo.yan@linaro.org> References: <20201111071149.815-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch defines macros for counter packet header, and uses macros to replace hard code values in functions arm_spe_get_counter() and arm_spe_pkt_desc(). In the function arm_spe_get_counter(), adds a new line for more readable. Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 11 ++++++----- tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 5 +++++ 2 files changed, 11 insertions(+), 5 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 e8c9da1d4280..5178bbe64422 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 @@ -152,10 +152,11 @@ static int arm_spe_get_counter(const unsigned char *buf, size_t len, const unsigned char ext_hdr, struct arm_spe_pkt *packet) { packet->type = ARM_SPE_COUNTER; + if (ext_hdr) - packet->index = ((buf[0] & 0x3) << 3) | (buf[1] & 0x7); + packet->index = SPE_HDR_EXTENDED_INDEX(buf[0], buf[1]); else - packet->index = buf[0] & 0x7; + packet->index = SPE_HDR_SHORT_INDEX(buf[0]); return arm_spe_get_payload(buf, len, ext_hdr, packet); } @@ -333,13 +334,13 @@ static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet, (unsigned short)payload); switch (packet->index) { - case 0: + case SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT: arm_spe_pkt_snprintf(&err, &buf, &buf_len, "TOT"); break; - case 1: + case SPE_CNT_PKT_HDR_INDEX_ISSUE_LAT: arm_spe_pkt_snprintf(&err, &buf, &buf_len, "ISSUE"); break; - case 2: + case SPE_CNT_PKT_HDR_INDEX_TRANS_LAT: arm_spe_pkt_snprintf(&err, &buf, &buf_len, "XLAT"); break; default: diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h index 9bc876bffd35..7d8e34e35f05 100644 --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h @@ -82,6 +82,11 @@ struct arm_spe_pkt { /* Context packet header */ #define SPE_CTX_PKT_HDR_INDEX(h) ((h) & GENMASK_ULL(1, 0)) +/* Counter packet header */ +#define SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT 0x0 +#define SPE_CNT_PKT_HDR_INDEX_ISSUE_LAT 0x1 +#define SPE_CNT_PKT_HDR_INDEX_TRANS_LAT 0x2 + const char *arm_spe_pkt_name(enum arm_spe_pkt_type); int arm_spe_get_packet(const unsigned char *buf, size_t len, -- 2.17.1