DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ruifeng Wang <ruifeng.wang@arm.com>
To: David Christensen <drc@linux.vnet.ibm.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
	Chao Zhu <chaozhu@linux.vnet.ibm.com>,
	Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
Cc: dev@dpdk.org, nd@arm.com, jerinj@marvell.com,
	honnappa.nagarahalli@arm.com, Ruifeng Wang <ruifeng.wang@arm.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] lpm: fix vector lookup for ppc64
Date: Fri,  8 Jan 2021 08:21:25 +0000	[thread overview]
Message-ID: <20210108082127.1061538-4-ruifeng.wang@arm.com> (raw)
In-Reply-To: <20210108082127.1061538-1-ruifeng.wang@arm.com>

rte_lpm_lookupx4 could return wrong next hop when more than 256 tbl8
groups are created. This is caused by incorrect type casting of tbl8
group index that been stored in tbl24 entry. The casting caused group
index truncation and hence wrong tbl8 group been searched.

Issue fixed by applying proper mask to tbl24 entry to get tbl8 group index.

Fixes: d2cc7959342b ("lpm: add AltiVec for ppc64")
Cc: gowrishankar.m@linux.vnet.ibm.com
Cc: stable@dpdk.org

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/librte_lpm/rte_lpm_altivec.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm_altivec.h b/lib/librte_lpm/rte_lpm_altivec.h
index 228c41b38..4fbc1b595 100644
--- a/lib/librte_lpm/rte_lpm_altivec.h
+++ b/lib/librte_lpm/rte_lpm_altivec.h
@@ -88,28 +88,28 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],
 	if (unlikely((pt & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[0] = i8.u32[0] +
-			(uint8_t)tbl[0] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[0] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[0]];
 		tbl[0] = *ptbl;
 	}
 	if (unlikely((pt >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[1] = i8.u32[1] +
-			(uint8_t)tbl[1] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[1] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[1]];
 		tbl[1] = *ptbl;
 	}
 	if (unlikely((pt2 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[2] = i8.u32[2] +
-			(uint8_t)tbl[2] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[2] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[2]];
 		tbl[2] = *ptbl;
 	}
 	if (unlikely((pt2 >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[3] = i8.u32[3] +
-			(uint8_t)tbl[3] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[3] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[3]];
 		tbl[3] = *ptbl;
 	}
-- 
2.25.1


  parent reply	other threads:[~2021-01-08  8:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  8:21 [dpdk-dev] [PATCH 0/4] lpm lookupx4 fixes Ruifeng Wang
2021-01-08  8:21 ` [dpdk-dev] [PATCH 1/4] lpm: fix vector lookup for Arm Ruifeng Wang
2021-01-08  8:21 ` [dpdk-dev] [PATCH 2/4] lpm: fix vector lookup for x86 Ruifeng Wang
2021-01-13 18:46   ` Medvedkin, Vladimir
2021-01-08  8:21 ` Ruifeng Wang [this message]
2021-01-11 21:29   ` [dpdk-dev] [PATCH 3/4] lpm: fix vector lookup for ppc64 David Christensen
2021-01-08  8:21 ` [dpdk-dev] [PATCH 4/4] test/lpm: improve coverage on tbl8 Ruifeng Wang
2021-01-11 21:29   ` David Christensen
2021-01-13 18:51   ` Medvedkin, Vladimir
2021-01-14  6:38     ` Ruifeng Wang
2021-01-13 14:52 ` [dpdk-dev] [PATCH 0/4] lpm lookupx4 fixes David Marchand
2021-01-14  6:54   ` Ruifeng Wang
2021-01-13 18:46 ` Medvedkin, Vladimir
2021-01-14  6:59 ` [dpdk-dev] [PATCH v2 " Ruifeng Wang
2021-01-14  6:59   ` [dpdk-dev] [PATCH v2 1/4] lpm: fix vector lookup for Arm Ruifeng Wang
2021-01-14  6:59   ` [dpdk-dev] [PATCH v2 2/4] lpm: fix vector lookup for x86 Ruifeng Wang
2021-01-14  6:59   ` [dpdk-dev] [PATCH v2 3/4] lpm: fix vector lookup for ppc64 Ruifeng Wang
2021-01-14  6:59   ` [dpdk-dev] [PATCH v2 4/4] test/lpm: improve coverage on tbl8 Ruifeng Wang
2021-01-14 11:14     ` Medvedkin, Vladimir
2021-01-14 15:25   ` [dpdk-dev] [PATCH v2 0/4] lpm lookupx4 fixes David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210108082127.1061538-4-ruifeng.wang@arm.com \
    --to=ruifeng.wang@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=chaozhu@linux.vnet.ibm.com \
    --cc=dev@dpdk.org \
    --cc=drc@linux.vnet.ibm.com \
    --cc=gowrishankar.m@linux.vnet.ibm.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=jerinj@marvell.com \
    --cc=nd@arm.com \
    --cc=stable@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).