From patchwork Wed Feb 24 12:42:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 386839 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp341697jap; Wed, 24 Feb 2021 04:43:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYxB7ZyC8Kd820IGClWi9TLopIYguZEEQ/HKwG5GuKS+tL+OwodczDaEgufaAa071YAqBx X-Received: by 2002:a17:907:111b:: with SMTP id qu27mr32089806ejb.453.1614170614770; Wed, 24 Feb 2021 04:43:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614170614; cv=none; d=google.com; s=arc-20160816; b=aPTIX8SqfrVsQNpsEG3CuTQTQXVpkzB+x0agaJJQQuIB29xfUXjMIY1WdsfJhZWw/F WKCH0cnTTcgrKN2Pmb2tFyW+2q+p1GUFmqMZqqYsKptm3+FWbMbEjgTuBFmaVDhYY798 0SLoDk+1beZrLddVZsmZPS35+G7YKChiz5ThF0/VXoOeNOkToGtZi8QDZsfXBY/kG72D BQnDC/QjnwwvrckUXE7eeQ/350eX/Dow59zv/D3GgSOMCNY5FUzDHDYRuOV9mnF27LTi NGOJTzNmiD7FaTzVkm8Hd3oWPAdMCADdMW27OVkmLn+CbtCOt8rVtLIZifQ+pF3iMCak qTIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=AF0Hli0s9QwP979nKJFxjj3wWBrDRt2Uc4vg9MtmHjY=; b=GuWoV9kAtqtWW3u9RVy+WyN0NTvets3O8QSmbAsrEWXO/h6xq0Lr+gpn2qK9n7gwJB oqRSykhLOosJDL8kWDHkHyozS+N3O7dqnUZg4ymE19BiXc3RhxbE6CwIUwKyMXmf8Qtw YFTrWBBWY9K1LTUAMXpjqIDkhtoW+A7eCkSZcuDQ/4pvT91mSXuXHCYVwaqNvshQBP6v bOllIFqkRnPfMLANOZjWtp7YGbkh/iQIZcivgnqMYACb0Bp4mm/kvAMz9le4MXzdizJb XxSRlKAcPRsn5YLK6vWU02mWH+rw9vk6Ouk2+1OYQAOungsBrxIz1D6Bp+eQ70uBNGzX rehw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id g13si1272869ejo.464.2021.02.24.04.43.34; Wed, 24 Feb 2021 04:43:34 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3227D16083C; Wed, 24 Feb 2021 13:43:23 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 0C47F16082D; Wed, 24 Feb 2021 13:43:21 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id C0DE51A0396; Wed, 24 Feb 2021 13:43:20 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3E35F1A0391; Wed, 24 Feb 2021 13:43:18 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A4F6B40324; Wed, 24 Feb 2021 13:43:14 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, stable@dpdk.org, Nipun Gupta Date: Wed, 24 Feb 2021 18:12:50 +0530 Message-Id: <20210224124311.29799-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210224124311.29799-1-hemant.agrawal@nxp.com> References: <20210211141620.12482-1-hemant.agrawal@nxp.com> <20210224124311.29799-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 02/23] bus/dpaa: fix statistics reading X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Nipun Gupta Reading of word un-aligned values after reading word aligned values lead to corrution of memory, such that older value. This patch make changes such that word alignedaccess is made, before making an un-aligned access Fixes: 6d6b4f49a155 ("bus/dpaa: add FMAN hardware operations") Cc: stable@dpdk.org Signed-off-by: Nipun Gupta Acked-by: Hemant Agrawal --- drivers/bus/dpaa/base/fman/fman_hw.c | 33 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c b/drivers/bus/dpaa/base/fman/fman_hw.c index 4ab49f7853..af9bac76c2 100644 --- a/drivers/bus/dpaa/base/fman/fman_hw.c +++ b/drivers/bus/dpaa/base/fman/fman_hw.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017 NXP + * Copyright 2017,2020 NXP * */ @@ -219,20 +219,20 @@ fman_if_stats_get(struct fman_if *p, struct rte_eth_stats *stats) struct memac_regs *regs = m->ccsr_map; /* read recved packet count */ - stats->ipackets = ((u64)in_be32(®s->rfrm_u)) << 32 | - in_be32(®s->rfrm_l); - stats->ibytes = ((u64)in_be32(®s->roct_u)) << 32 | - in_be32(®s->roct_l); - stats->ierrors = ((u64)in_be32(®s->rerr_u)) << 32 | - in_be32(®s->rerr_l); + stats->ipackets = (u64)in_be32(®s->rfrm_l) | + ((u64)in_be32(®s->rfrm_u)) << 32; + stats->ibytes = (u64)in_be32(®s->roct_l) | + ((u64)in_be32(®s->roct_u)) << 32; + stats->ierrors = (u64)in_be32(®s->rerr_l) | + ((u64)in_be32(®s->rerr_u)) << 32; /* read xmited packet count */ - stats->opackets = ((u64)in_be32(®s->tfrm_u)) << 32 | - in_be32(®s->tfrm_l); - stats->obytes = ((u64)in_be32(®s->toct_u)) << 32 | - in_be32(®s->toct_l); - stats->oerrors = ((u64)in_be32(®s->terr_u)) << 32 | - in_be32(®s->terr_l); + stats->opackets = (u64)in_be32(®s->tfrm_l) | + ((u64)in_be32(®s->tfrm_u)) << 32; + stats->obytes = (u64)in_be32(®s->toct_l) | + ((u64)in_be32(®s->toct_u)) << 32; + stats->oerrors = (u64)in_be32(®s->terr_l) | + ((u64)in_be32(®s->terr_u)) << 32; } void @@ -244,10 +244,9 @@ fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n) uint64_t base_offset = offsetof(struct memac_regs, reoct_l); for (i = 0; i < n; i++) - value[i] = ((u64)in_be32((char *)regs - + base_offset + 8 * i + 4)) << 32 | - ((u64)in_be32((char *)regs - + base_offset + 8 * i)); + value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) | + (u64)in_be32((char *)regs + base_offset + + 8 * i + 4)) << 32); } void