From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8FDD44552F;
	Mon,  8 Jul 2024 14:14:27 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 4ECA740E42;
	Mon,  8 Jul 2024 14:14:23 +0200 (CEST)
Received: from foss.arm.com (foss.arm.com [217.140.110.172])
 by mails.dpdk.org (Postfix) with ESMTP id 6F2A8402F1
 for <dev@dpdk.org>; Mon,  8 Jul 2024 14:14:21 +0200 (CEST)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0BC381650;
 Mon,  8 Jul 2024 05:14:46 -0700 (PDT)
Received: from ampere-altra-2-3.austin.arm.com
 (ampere-altra-2-3.austin.arm.com [10.118.14.97])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D69113F86F;
 Mon,  8 Jul 2024 05:14:20 -0700 (PDT)
From: Yoan Picchi <yoan.picchi@arm.com>
To: Yipeng Wang <yipeng1.wang@intel.com>,
 Sameh Gobriel <sameh.gobriel@intel.com>,
 Bruce Richardson <bruce.richardson@intel.com>,
 Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Cc: dev@dpdk.org,
	nd@arm.com,
	Yoan Picchi <yoan.picchi@arm.com>
Subject: [PATCH v12 3/7] hash: add a check on hash entry max size
Date: Mon,  8 Jul 2024 12:14:07 +0000
Message-Id: <20240708121411.885996-4-yoan.picchi@arm.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20240708121411.885996-1-yoan.picchi@arm.com>
References: <20231020165159.1649282-1-yoan.picchi@arm.com>
 <20240708121411.885996-1-yoan.picchi@arm.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

If were to change RTE_HASH_BUCKET_ENTRIES to be over 8, it would no longer
fit in the vector (8*16b=128b), therefore failing to check some of the
signatures. This patch adds a compile time check to fallback to scalar
code in this case.

Signed-off-by: Yoan Picchi <yoan.picchi@arm.com>
---
 lib/hash/compare_signatures_arm.h | 2 +-
 lib/hash/compare_signatures_x86.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/hash/compare_signatures_arm.h b/lib/hash/compare_signatures_arm.h
index 80b6afb7a5..74b3286c95 100644
--- a/lib/hash/compare_signatures_arm.h
+++ b/lib/hash/compare_signatures_arm.h
@@ -23,7 +23,7 @@ compare_signatures(uint32_t *prim_hash_matches, uint32_t *sec_hash_matches,
 
 	/* For match mask the first bit of every two bits indicates the match */
 	switch (sig_cmp_fn) {
-#if defined(__ARM_NEON)
+#if defined(__ARM_NEON) && RTE_HASH_BUCKET_ENTRIES <= 8
 	case RTE_HASH_COMPARE_NEON: {
 		uint16x8_t vmat, vsig, x;
 		int16x8_t shift = {-15, -13, -11, -9, -7, -5, -3, -1};
diff --git a/lib/hash/compare_signatures_x86.h b/lib/hash/compare_signatures_x86.h
index 11a82aced9..f77b37f1cd 100644
--- a/lib/hash/compare_signatures_x86.h
+++ b/lib/hash/compare_signatures_x86.h
@@ -23,7 +23,7 @@ compare_signatures(uint32_t *prim_hash_matches, uint32_t *sec_hash_matches,
 
 	/* For match mask the first bit of every two bits indicates the match */
 	switch (sig_cmp_fn) {
-#if defined(__SSE2__)
+#if defined(__SSE2__) && RTE_HASH_BUCKET_ENTRIES <= 8
 	case RTE_HASH_COMPARE_SSE:
 		/* Compare all signatures in the bucket */
 		*prim_hash_matches = _mm_movemask_epi8(_mm_cmpeq_epi16(_mm_load_si128(
-- 
2.25.1