[RFC,08/12] hash: add support for s390x architecture

Message ID 20190409190630.31975-9-vivkong@ca.ibm.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series introduce s390x architecture |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Vivian Kong April 9, 2019, 7:06 p.m. UTC
  Add big endian support for s390x architecture.

Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
---
 lib/librte_hash/rte_fbk_hash.h | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Dharmik Thakkar April 15, 2019, 8:43 p.m. UTC | #1
Hi,
Please find the inline comment.

> On Apr 9, 2019, at 2:06 PM, Vivian Kong <vivkong@gmail.com> wrote:
> 
> Add big endian support for s390x architecture.
> 
> Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
> ---
> lib/librte_hash/rte_fbk_hash.h | 7 +++++++
> 1 file changed, 7 insertions(+)
> 
> diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
> index c4d6976d2..5e49950a7 100644
> --- a/lib/librte_hash/rte_fbk_hash.h
> +++ b/lib/librte_hash/rte_fbk_hash.h
> @@ -125,9 +125,16 @@ rte_fbk_hash_add_key_with_bucket(struct rte_fbk_hash_table *ht,
> 	 * corrupted due to race conditions, but it's still possible to
> 	 * overwrite entries that have just been made valid.
> 	 */
> +	#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
> 	const uint64_t new_entry = ((uint64_t)(key) << 32) |
> 			((uint64_t)(value) << 16) |
> 			1;  /* 1 = is_entry bit. */
> +	#else
> +	const uint64_t new_entry =
> +			((uint64_t)(1) << 48) | /* 1 = is_entry bit. */
((uint64_t)(1) << 56)?
> +			((uint64_t)(value) << 32) |
> +			(uint64_t)(key);
> +	#endif
> 	uint32_t i;
> 
> 	for (i = 0; i < ht->entries_per_bucket; i++) {
> -- 
> 2.17.1
>
  

Patch

diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index c4d6976d2..5e49950a7 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -125,9 +125,16 @@  rte_fbk_hash_add_key_with_bucket(struct rte_fbk_hash_table *ht,
 	 * corrupted due to race conditions, but it's still possible to
 	 * overwrite entries that have just been made valid.
 	 */
+	#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 	const uint64_t new_entry = ((uint64_t)(key) << 32) |
 			((uint64_t)(value) << 16) |
 			1;  /* 1 = is_entry bit. */
+	#else
+	const uint64_t new_entry =
+			((uint64_t)(1) << 48) | /* 1 = is_entry bit. */
+			((uint64_t)(value) << 32) |
+			(uint64_t)(key);
+	#endif
 	uint32_t i;
 
 	for (i = 0; i < ht->entries_per_bucket; i++) {