Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp151495pxb; Tue, 10 Nov 2020 23:25:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0l83BjJ9AXHKab0ajSly206mtTH61KQsI7dljLBkhvbr5Dhx+4s8sqtjq0ZBE/oWlMxNK X-Received: by 2002:aa7:cd9a:: with SMTP id x26mr2202451edv.226.1605079548937; Tue, 10 Nov 2020 23:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605079548; cv=none; d=google.com; s=arc-20160816; b=QNFVu9RBMZOjHj/OdrsRxtaRdpe/iptBNfhs0WAbsOU4iTP/Fvm6qlXmyuupfXHE5E tdgiecyNoXP3EaIG6NtxNZo/owugaaS62dcub/C5UYOGkcWYZ9b19V5pPBy1eNdWZ9zs TY2O0G8x9u+blYlWS5wFPE8vGMHSA0UKszia4jjlop0MNW3lW751j95wFT3h3Gl1BngZ vBkq1ahaAoQNK8OsMabhFLY7FyTMoyqIIQbTT4/9hDp1upyeXtQCC4ebt6RMF7SL0zqh XO32B8C4usBeXi5CC4Sh0iiyPUP6Z5wPdl1s0VmRTDlqHGI7pLCkyAyAq+/LExRqXL5y ws1A== 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=nkc6abxqhANiOnEXKEdBYwP6x6Xfev71i31URK+LSvc=; b=Dx00tCnD+A2Z4V3S9yGwxHhZjiGK1czplm4b9BvjvK8O2KhKdVI+bMmE5zcIkiEYd5 sVimYJlcpbi4ejFITWa/WL8q/q27FCUr5f43JOoUFXWMVbR98qftWr0rkpvr6+krmzjE pdC5+vHGX+RHQfLjizVK7pzwAZKz9s1s/2iYlU0Pb3ybA+mJzYdpamxVpYLyH42ctHIY ybkZe9t60/WZQczIBRm6MgXJeoL2hsA130vp0cDXxFYCduSxhjGex3ldoOlZoGHO0YAT cD8Wj24isVYzXf+OE1X+P8Vy7l0wax5ftbSUITppx2EebyIaLgdARZxIdEmQ4FoFOvxr 1/Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="b96/7jqG"; 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 lc8si753409ejb.278.2020.11.10.23.25.25; Tue, 10 Nov 2020 23:25:48 -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="b96/7jqG"; 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 S1726544AbgKKHUj (ORCPT + 99 others); Wed, 11 Nov 2020 02:20:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbgKKHO0 (ORCPT ); Wed, 11 Nov 2020 02:14:26 -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 76282C061A4B for ; Tue, 10 Nov 2020 23:13:27 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id x13so1057206pfa.9 for ; Tue, 10 Nov 2020 23:13:27 -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=nkc6abxqhANiOnEXKEdBYwP6x6Xfev71i31URK+LSvc=; b=b96/7jqGZ71xI37TvtYG+ML6oGa0iyKBdlht48VIZapSm2RgcByBCMebNfEGhrJvpn jYRzrors6J71vG+EByybt7nbFAQy7SVQm3Cv7z5YkMlzf4I7X4vAUXDuKScDJz02lPLJ o3FKqQGOU5C+ggSHL+PQtyULfX5viFZ9fiJ28mczp++bCfxNdSIGcs3QNZNO8Y3tiCYG q9MV0HrvwQ5oBl0la833s+teU7M1bXxEBUj5QxKmeklN55S+AQCfhihkdgfdC4k4hzUe XJFA7j6DRv8k5IW9A77N4mhQTHNN9W+J/UCK+bDDtKCANL2kENTSmzGfwz3S8AYtE2ky hz3Q== 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=nkc6abxqhANiOnEXKEdBYwP6x6Xfev71i31URK+LSvc=; b=ammqiUdmLUo0QDMBJ+/+i+698OgpTkpsDc89l+g0CVg4eS79Gtll2ymM8UzLVSx4+/ prTV/s/zPOCqtoe3DMyK+Od8Qo5o/yf2CgMdTGtkTgU6eT3DFKItwmUg0UfWvkaRfjoZ uAxCiB0nxFeggbY1Ppuw+5QRL+ylTKL4o7iLd0fTQ7SaOifpQdUfhaCZkOCxLRypRn5R CWsMAU7dqoRGHFL2G2njfTGzjVLAizM8G6OeKIkdNYT2Q8OlIolyX10tBpSb7/FiGVYt EKugeZY7ml0RGvHsCod61Hz6hRcRMpUo6NHKVelv5AAdcs4IIi5g68gM106Muje8IuxZ K7hA== X-Gm-Message-State: AOAM5332OIftHl93FZtdI6R1HMucXkeaQozKXV8aYzdBa+Z38SvSE5Zj 9sjcIiBIQ2NbQDAI40fJodtQOQ== X-Received: by 2002:a63:cb47:: with SMTP id m7mr8468065pgi.395.1605078806911; Tue, 10 Nov 2020 23:13:26 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id n6sm1330715pfj.209.2020.11.10.23.13.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Nov 2020 23:13:26 -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 18/22] perf arm-spe: Add new function arm_spe_pkt_desc_op_type() Date: Wed, 11 Nov 2020 15:11:45 +0800 Message-Id: <20201111071149.815-19-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 The operation type packet is complex and contains subclass; the parsing flow causes deep indentation; for more readable, this patch introduces a new function arm_spe_pkt_desc_op_type() which is used for operation type parsing. Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- .../arm-spe-decoder/arm-spe-pkt-decoder.c | 79 +++++++++++-------- 1 file changed, 45 insertions(+), 34 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 64811021f36c..4f93b75c87e6 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 @@ -321,6 +321,50 @@ static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet, return err; } +static int arm_spe_pkt_desc_op_type(const struct arm_spe_pkt *packet, + char *buf, size_t buf_len) +{ + u64 payload = packet->payload; + int err = 0; + + switch (packet->index) { + case 0: + arm_spe_pkt_snprintf(&err, &buf, &buf_len, + payload & 0x1 ? "COND-SELECT" : "INSN-OTHER"); + break; + case 1: + arm_spe_pkt_snprintf(&err, &buf, &buf_len, + payload & 0x1 ? "ST" : "LD"); + + if (payload & 0x2) { + if (payload & 0x4) + arm_spe_pkt_snprintf(&err, &buf, &buf_len, " AT"); + if (payload & 0x8) + arm_spe_pkt_snprintf(&err, &buf, &buf_len, " EXCL"); + if (payload & 0x10) + arm_spe_pkt_snprintf(&err, &buf, &buf_len, " AR"); + } else if (payload & 0x4) { + arm_spe_pkt_snprintf(&err, &buf, &buf_len, " SIMD-FP"); + } + break; + case 2: + arm_spe_pkt_snprintf(&err, &buf, &buf_len, "B"); + + if (payload & 0x1) + arm_spe_pkt_snprintf(&err, &buf, &buf_len, " COND"); + if (payload & 0x2) + arm_spe_pkt_snprintf(&err, &buf, &buf_len, " IND"); + + break; + default: + /* Unknown index */ + err = -1; + break; + } + + return err; +} + static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet, char *buf, size_t buf_len) { @@ -404,40 +448,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, err = arm_spe_pkt_desc_event(packet, buf, buf_len); break; case ARM_SPE_OP_TYPE: - switch (idx) { - case 0: - arm_spe_pkt_snprintf(&err, &buf, &blen, - payload & 0x1 ? "COND-SELECT" : "INSN-OTHER"); - break; - case 1: - arm_spe_pkt_snprintf(&err, &buf, &blen, - payload & 0x1 ? "ST" : "LD"); - - if (payload & 0x2) { - if (payload & 0x4) - arm_spe_pkt_snprintf(&err, &buf, &blen, " AT"); - if (payload & 0x8) - arm_spe_pkt_snprintf(&err, &buf, &blen, " EXCL"); - if (payload & 0x10) - arm_spe_pkt_snprintf(&err, &buf, &blen, " AR"); - } else if (payload & 0x4) { - arm_spe_pkt_snprintf(&err, &buf, &blen, " SIMD-FP"); - } - break; - case 2: - arm_spe_pkt_snprintf(&err, &buf, &blen, "B"); - - if (payload & 0x1) - arm_spe_pkt_snprintf(&err, &buf, &blen, " COND"); - if (payload & 0x2) - arm_spe_pkt_snprintf(&err, &buf, &blen, " IND"); - - break; - default: - /* Unknown index */ - err = -1; - break; - } + err = arm_spe_pkt_desc_op_type(packet, buf, buf_len); break; case ARM_SPE_DATA_SOURCE: case ARM_SPE_TIMESTAMP: -- 2.17.1