Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp930855pxb; Thu, 5 Nov 2020 17:44:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSrgP3aFSoXxjYdeS/jaygoXbKv1OimKQpD4jYReM8HLUaPpmsOAPh68jo64KXs6uzBw42 X-Received: by 2002:a17:906:c20f:: with SMTP id d15mr5130907ejz.341.1604627058984; Thu, 05 Nov 2020 17:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604627058; cv=none; d=google.com; s=arc-20160816; b=OjHkf5oiqalCH72ghheQgp4LdR8O2fXVGHXYsW/f6+Y4QcUKaU1A2R12jQHeQiTwbX u6tNQf1kwOcIQfeSqEOm1DqJBFNVtYOFo6O9QrJxpcPM9eSJhmBFECo6+k2mL2tT4Vqm 2M7QKv3myJdMGh6O/LroOJAfJYPrwx21rR+WB7PK4uDpjjTQ1oDEajfrCDM6fWSv2wAr lhQEhcfYyLz833zzkUpdV+acOStrgYXNwqdkpHHm+BeH/BcSzPYOHar03ufpMAhP40ZU MnfUkXW9B5DNKUsOhstgL4lcKA6Qg9WEAjM8Gki7fsSUiOJCb7S+t1/OZOnE87NQqfmI 4fPg== 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=Re9txxlgEUEpxxffpKQDQFN978aw9VSYLQsYYRx+ZCo=; b=wHdas3Kzys2k4L9Iy/hLrJapDpnxnb3ko3SJ9V1yZ4e0Yx85Il6HaQGfcWsAzCzIYc UJEOO+2ODGYf/ePQKiOk+hr610faZXjMpRN5BNpxG31slg7bj40pxTxk0nTkDIWPjbWW JM+BaEi//dEif6K8A3bEPw/FQjNjCRQSXyPxTqAoBO+4XQ0zkvlNbCCd6im/+TZ0C1jg HdwkIr4fNv8q/238sgZ1zIBQNHy/H94w4TCXjKFi8zocQGDKS0wOv0K+wzB+qqje0K68 AL+T3gp+vf6MINQlc+bZ8Uj5zfeKtyxV8MouDyL506PDKwxUUY7RW9+t9ELYovKlh6Nd 3v2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mHxG0Xuc; 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 lz6si2503496ejb.116.2020.11.05.17.43.56; Thu, 05 Nov 2020 17:44:18 -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=mHxG0Xuc; 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 S1732921AbgKFBmO (ORCPT + 99 others); Thu, 5 Nov 2020 20:42:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732916AbgKFBmO (ORCPT ); Thu, 5 Nov 2020 20:42:14 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42355C0613CF for ; Thu, 5 Nov 2020 17:42:14 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id g12so2691417pgm.8 for ; Thu, 05 Nov 2020 17:42:14 -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=Re9txxlgEUEpxxffpKQDQFN978aw9VSYLQsYYRx+ZCo=; b=mHxG0XucKlKyFux2FQjJ+ADBaB6fZQemguAZNDx5uyw/7MPxU1nG12pAk/yNjiA1Ow QvwoZ1J/OhOlnfZjnG1bjNYciLQbML0ZVcH4mRDux0+v/GDS3la6BpacKVY9XEOAtkbW oRde5NvD/FgF6J7Yei1at8+mV8ridgDbnEGxOsqNSzmlUAL2MOGj8wdEx8lMVoJs4Dy2 5+B6h3/yjooEgSXdNd7nMKsZ73cBnqwLTXcDp5Q9Bu9kDpH9csnKVG+yu3NRkyiXaH8N vpS/EGeaBa0MPJVdT7dX55jpa9n852r9vJijhJJyM98/yY0wimJrv7sg9c86x894cRVc MClQ== 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=Re9txxlgEUEpxxffpKQDQFN978aw9VSYLQsYYRx+ZCo=; b=Me1u+g0csZFj5rPUk9bccVW/n+89gaQ9WOdhqp4bfKm8mkoQsppu3wwb1pNygq+Yqr VNHuK5PbwsBVZAyHmG/+sg5CQIBfVq3h8N+lW7hvxGyWQbqjqzreX5jjGMxJzl7Q/F8Z gqLWfWOrwuk60bwPKdSfrJKL8DxQtpOaC+y8BZAIWT4PONHSpaswFYkJtGrlYcARZoiq HqRefG6kTZ2ufx4hmoyju3q3l+1aKGRn+nDPYtxAWVhLmMAmUbpaNBAhWIkCBBgAJVPr 3kNiv1860WDzkD8Y31xgMRmxtFQY4jQfE8V22C8UV6dVODiFPXB6CDmDeKYVg1KEc0JD 9Cig== X-Gm-Message-State: AOAM530473rh3M3j5JYH5xpJ9JghmPB0v+grXIlTNzmR9bz83j9Is4qA InMBwGbw0sLv5TV6NDW3iCjYJg== X-Received: by 2002:a63:c750:: with SMTP id v16mr5108080pgg.424.1604626933858; Thu, 05 Nov 2020 17:42:13 -0800 (PST) Received: from localhost ([2400:8904::f03c:91ff:fe8a:adf7]) by smtp.gmail.com with ESMTPSA id q23sm3996129pfg.192.2020.11.05.17.42.12 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Nov 2020 17:42:13 -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 , linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v7 03/22] perf arm-spe: Refactor payload size calculation Date: Fri, 6 Nov 2020 09:41:17 +0800 Message-Id: <20201106014136.14103-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201106014136.14103-1-leo.yan@linaro.org> References: <20201106014136.14103-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch defines macro to extract "sz" field from header, and renames the function payloadlen() to arm_spe_payload_len(). Signed-off-by: Leo Yan Reviewed-by: Andre Przywara --- .../util/arm-spe-decoder/arm-spe-pkt-decoder.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 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 7c7b5eb09fba..06b3eec4494e 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 @@ -69,22 +69,22 @@ const char *arm_spe_pkt_name(enum arm_spe_pkt_type type) return arm_spe_packet_name[type]; } -/* return ARM SPE payload size from its encoding, - * which is in bits 5:4 of the byte. - * 00 : byte - * 01 : halfword (2) - * 10 : word (4) - * 11 : doubleword (8) +/* + * Extracts the field "sz" from header bits and converts to bytes: + * 00 : byte (1) + * 01 : halfword (2) + * 10 : word (4) + * 11 : doubleword (8) */ -static int payloadlen(unsigned char byte) +static unsigned int arm_spe_payload_len(unsigned char hdr) { - return 1 << ((byte & 0x30) >> 4); + return 1U << ((hdr & GENMASK_ULL(5, 4)) >> 4); } static int arm_spe_get_payload(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet) { - size_t payload_len = payloadlen(buf[0]); + size_t payload_len = arm_spe_payload_len(buf[0]); if (len < 1 + payload_len) return ARM_SPE_NEED_MORE_BYTES; -- 2.17.1